Skip to content

Instantly share code, notes, and snippets.

@rfay
Created March 16, 2022 00:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfay/816600d93d386d34f883146dd529ea45 to your computer and use it in GitHub Desktop.
Save rfay/816600d93d386d34f883146dd529ea45 to your computer and use it in GitHub Desktop.
Updated healthcheck.sh and other files for mailhog with basic auth
ARG BASE_IMAGE
FROM $BASE_IMAGE
ADD mailhog-auth.txt /etc
ADD mailhog.conf /etc/supervisor/conf.d
ADD healthcheck.sh /
#!/bin/bash
# ddev-webserver healthcheck
set -eo pipefail
sleeptime=59
# Make sure that both phpstatus, mounted code, and mailhog
# are working.
# Since docker doesn't provide a lazy period for startup,
# we track health. If the last check showed healthy
# as determined by existence of /tmp/healthy, then
# sleep at startup. This requires the timeout to be set
# higher than the sleeptime used here.
if [ -f /tmp/healthy ]; then
printf "container was previously healthy, so sleeping ${sleeptime} seconds before continuing healthcheck... "
sleep ${sleeptime}
fi
phpstatus="false"
htmlaccess="false"
mailhog="true" # Ignore mailhog status because we're using auth
if curl --fail -s 127.0.0.1/phpstatus >/dev/null ; then
phpstatus="true"
printf "phpstatus: OK "
else
printf "phpstatus: FAILED "
fi
if ls /var/www/html >/dev/null; then
htmlaccess="true"
printf "/var/www/html: OK "
else
printf "/var/www/html: FAILED"
fi
if curl --fail -s 127.0.0.1:8025 >/dev/null; then
mailhog="true"
printf "mailhog: OK " ;
else
printf "mailhog: FAILED "
fi
if [ "${phpstatus}" = "true" ] && [ "${htmlaccess}" = "true" ] && [ "${mailhog}" = "true" ] ; then
touch /tmp/healthy
exit 0
fi
rm -f /tmp/healthy
exit 1
test:$2a$04$qxRo.ftFoNep7ld/5jfKtuBTnGqff/fZVyj53mUC5sVf9dtDLAi/S
[program:mailhog]
command=/usr/local/bin/mailhog -auth-file=/etc/mailhog-auth.txt
autorestart=true
startretries=10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment