diff --git a/Dockerfile b/Dockerfile index f1208db..7e8f82e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,21 +3,16 @@ FROM crosbymichael/golang MAINTAINER James Hillyerd, @jameshillyerd -# Install Inbucket +# Configuration (WORKDIR doesn't support env vars) +ENV INBUCKET_SRC $GOPATH/src/github.com/jhillyerd/inbucket ENV INBUCKET_HOME /opt/inbucket -ADD inbucket $INBUCKET_HOME/inbucket -ADD themes $INBUCKET_HOME/themes -ADD etc/unix-sample.conf $INBUCKET_HOME/inbucket.conf - -# Volume for mail data -VOLUME /var/opt/inbucket - -# SMTP, HTTP, POP3 ports -EXPOSE 25 -EXPOSE 80 -EXPOSE 110 - -# Start Inbucket (WORKDIR doesn't support env vars) WORKDIR /opt/inbucket -ENTRYPOINT ["./inbucket"] -CMD ["inbucket.conf"] +ENTRYPOINT ["bin/inbucket"] +CMD ["/etc/opt/inbucket.conf"] + +# Ports: SMTP, HTTP, POP3 +EXPOSE 10025 10080 10110 + +# Build Inbucket +ADD . $INBUCKET_SRC/ +RUN "$INBUCKET_SRC/etc/docker/install.sh" diff --git a/docker-run.sh b/docker-run.sh new file mode 100755 index 0000000..115858b --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# docker-run.sh +# description: Launch Inbucket's docker image + +if [ "$UID" -ne 0 ]; then + sudo $0 "$@" +fi + +docker run -p 9000:10080 -p 2500:10025 -p 1100:10110 jhillyerd/inbucket diff --git a/etc/docker/greeting.html b/etc/docker/greeting.html new file mode 100644 index 0000000..d4e5be8 --- /dev/null +++ b/etc/docker/greeting.html @@ -0,0 +1,15 @@ +

Inbucket is an email testing service; it will accept email for any email +address and make it available to view without a password.

+ +

To view email for a particular address, enter the username portion +of the address into the box on the upper right and click go.

+ +

This instance of Inbucket is running inside of a Docker container. It is +configured to retain messages for a maximum of 3 days, and will enforce a limit +of 300 messages per mailbox - the oldest messages will be deleted to stay under +the limit.

+ +

Messages addressed to any recipient in the @bitbucket.local +domain will be accepted but not written to disk. Use this domain for load or +soak testing your application.

diff --git a/etc/docker/inbucket.conf b/etc/docker/inbucket.conf new file mode 100644 index 0000000..50f9055 --- /dev/null +++ b/etc/docker/inbucket.conf @@ -0,0 +1,110 @@ +# inbucket.conf +# Configuration for Inbucket inside of Docker +# +# These should be reasonable defaults for a production install of Inbucket + +############################################################################# +[DEFAULT] + +# Not used directly, but is typically referenced below in %()s format. +install.dir=/opt/inbucket +domain=inbucket.local + +############################################################################# +[logging] + +# Options from least to most verbose: ERROR, WARN, INFO, TRACE +level=INFO + +############################################################################# +[smtp] + +# IPv4 address to listen for SMTP connections on. +ip4.address=0.0.0.0 + +# IPv4 port to listen for SMTP connections on. +ip4.port=10025 + +# used in SMTP greeting +domain=inbucket.local + +# optional: mail sent to accounts at this domain will not be stored, +# for mixed use (content and load testing) +domain.nostore=bitbucket.local + +# Maximum number of RCPT TO: addresses we allow from clients, the SMTP +# RFC recommends this be at least 100. +max.recipients=100 + +# How long we allow a network connection to be idle before hanging up on the +# client, SMTP RFC recommends at least 5 minutes (300 seconds). +max.idle.seconds=300 + +# Maximum allowable size of message body in bytes (including attachments) +max.message.bytes=2048000 + +# Should we place messages into the datastore, or just throw them away +# (for load testing): true or false +store.messages=true + +############################################################################# +[pop3] + +# IPv4 address to listen for POP3 connections on. +ip4.address=0.0.0.0 + +# IPv4 port to listen for POP3 connections on. +ip4.port=10110 + +# used in POP3 greeting +domain=%(domain) + +# How long we allow a network connection to be idle before hanging up on the +# client, POP3 RFC requires at least 10 minutes (600 seconds). +max.idle.seconds=600 + +############################################################################# +[web] + +# IPv4 address to serve HTTP web interface on +ip4.address=0.0.0.0 + +# IPv4 port to serve HTTP web interface on +ip4.port=10080 + +# Name of web theme to use +theme=integral + +# Path to the selected themes template files +template.dir=%(install.dir)s/themes/%(theme)s/templates + +# Should we cache parsed templates (set to false during theme dev) +template.cache=true + +# Path to the selected themes public (static) files +public.dir=%(install.dir)s/themes/%(theme)s/public + +# Path to the greeting HTML displayed on front page, can +# be moved out of installation dir for customization +greeting.file=/etc/opt/inbucket-greeting.html + +############################################################################# +[datastore] + +# Path to the datastore, mail will be written into subdirectories +path=/var/opt/inbucket + +# How many minutes after receipt should a message be stored until it's +# automatically purged. To retain messages until manually deleted, set this +# to 0 +retention.minutes=4320 + +# How many milliseconds to sleep after purging messages from a mailbox. +# This should help reduce disk I/O when there are a large number of messages +# to purge. +retention.sleep.millis=100 + +# Maximum number of messages we will store in a single mailbox. If this +# number is exceeded, the oldest message in the box will be deleted each +# time a new message is received for it. +mailbox.message.cap=300 diff --git a/etc/docker/install.sh b/etc/docker/install.sh new file mode 100755 index 0000000..070d6d9 --- /dev/null +++ b/etc/docker/install.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# install.sh +# description: Build, test, and install Inbucket. Should be executed inside a Docker container. + +# Note: we assume there are no spaces in dir paths +installdir=${INBUCKET_HOME} +srcdir=${INBUCKET_SRC} +bindir=$installdir/bin + +# Setup +export GOBIN=$bindir +builddate="$(date --iso-8601=seconds)" +set -e +cd $srcdir +go clean + +# Build +echo "### Fetching Dependencies" +go get -d -v ./... +go get -v github.com/stretchr/testify + +echo "### Testing Inbucket" +go test ./... + +echo "### Building Inbucket" +mkdir -p $bindir +go build -o inbucket -race -ldflags "-X main.BUILD_DATE '$builddate'" -v . + +echo "### Installing Inbucket" +mv inbucket $bindir +install etc/docker/inbucket.conf /etc/opt/inbucket.conf +install etc/docker/greeting.html /etc/opt/inbucket-greeting.html +cp -r themes $installdir/