Skip to content

Instantly share code, notes, and snippets.

@adam187
Last active February 27, 2022 15:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam187/ae36813f0742ba0d0f9ee26757c3fbd7 to your computer and use it in GitHub Desktop.
Save adam187/ae36813f0742ba0d0f9ee26757c3fbd7 to your computer and use it in GitHub Desktop.
#/bin/bash
# Fail on first error
set -e
APP=${1?dokku app name required}
MAILCATCHER_APP=mailcatcher-${APP}
MAILCATCHER_APP_DOCKER_NAME=${MAILCATCHER_APP}.web.1
MAILCATCHER_HOST=${MAILCATCHER_APP}
MAILCATCHER_SMTP_PORT=1025
MAILCATCHER_SMTP_URL=smtp://${MAILCATCHER_HOST}:${MAILCATCHER_SMTP_PORT}
echo "Pulling mailcatcher image from docker registry"
docker pull schickling/mailcatcher
echo "Ensure that app exists"
dokku apps:report ${APP}
echo "Crete dokku app for mailcatcher"
dokku apps:create ${MAILCATCHER_APP}
echo "Tagging docker image with mailcatcher app tag"
docker tag schickling/mailcatcher:latest dokku/${MAILCATCHER_APP}:latest
echo "Configure mailcatcher port map"
dokku config:set ${MAILCATCHER_APP} DOKKU_PROXY_PORT_MAP="http:80:1080"
echo "Deploying mailcatcher app"
dokku tags:deploy ${MAILCATCHER_APP} latest
echo "Link app container with mailcatcher container"
dokku docker-options:add ${APP} deploy "--link ${MAILCATCHER_APP_DOCKER_NAME}:${MAILCATCHER_HOST}"
dokku docker-options:add ${APP} run "--link ${MAILCATCHER_APP_DOCKER_NAME}:${MAILCATCHER_HOST}"
echo "Setting SMTP_URL environment variable"
dokku config:set ${APP} SMTP_URL=${MAILCATCHER_SMTP_URL}
@yourivdlans
Copy link

yourivdlans commented Mar 18, 2019

Thanks for this!

I think the proxy port map is incorrect though. The mailcatcher dockerfile exposes port 1080.

So the Configure mailcatcher port map line should actually be:

dokku config:set ${MAILCATCHER_APP} DOKKU_PROXY_PORT_MAP="http:1080:1080"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment