Solved msmtp bug and implemented healthchecks for it

This commit is contained in:
2025-04-03 15:09:10 +02:00
parent 170636d098
commit e024542d8e
8 changed files with 39 additions and 43 deletions

View File

@@ -9,22 +9,9 @@ services:
- data:/var/www/html
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
healthcheck:
# This health check ensures the test email is sent only once to prevent
# hitting SMTP rate limits due to multiple health check executions.
# The logic checks for a temporary file (/tmp/email_sent) to determine
# if the email has already been sent. If the file exists, the email
# is skipped, but the health check continues by verifying the HTTP service.
# Refer to the conversation with ChatGPT (https://chatgpt.com/share/67898c3f-2c1c-800f-861c-47dcbe109135)
# on January 16, 2025, for the background behind this complexity.
test:
[
"CMD-SHELL",
"(if [ ! -f /tmp/email_sent ]; then echo 'Subject: testmessage from {{domains[application_id]}}\n\nSUCCESSFULL' | msmtp -t {{test_email}} && touch /tmp/email_sent; fi && curl -f http://127.0.0.1:80) || exit 1"
]
interval: 1m
timeout: 10s
retries: 3
{% include 'roles/docker-compose/templates/services/msmtp_curl_test.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'templates/docker/container/depends-on-just-database.yml.j2' %}