Created
March 16, 2022 00:55
-
-
Save rfay/816600d93d386d34f883146dd529ea45 to your computer and use it in GitHub Desktop.
Updated healthcheck.sh and other files for mailhog with basic auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG BASE_IMAGE | |
FROM $BASE_IMAGE | |
ADD mailhog-auth.txt /etc | |
ADD mailhog.conf /etc/supervisor/conf.d | |
ADD healthcheck.sh / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test:$2a$04$qxRo.ftFoNep7ld/5jfKtuBTnGqff/fZVyj53mUC5sVf9dtDLAi/S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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