diff --git a/platform/shell-sync/Dockerfile b/platform/shell-sync/Dockerfile index 572eab13..bf111d23 100644 --- a/platform/shell-sync/Dockerfile +++ b/platform/shell-sync/Dockerfile @@ -68,3 +68,16 @@ RUN chmod +x /usr/local/bin/imapsync /usr/local/bin/oauth2_imap \ && perl -c /usr/local/bin/oauth2_imap \ && imapsync --version +# Copy entrypoint +COPY sync.sh /sync.sh +RUN chmod +x /sync.sh && bash -n /sync.sh + +# Health is liveness plus notification delivery. Sync freshness is exposed by +# accountN.last_success / accountN.last_failure files for the chosen schedule. +HEALTHCHECK --interval=5m --timeout=10s --start-period=60s --retries=3 \ + CMD test -f "${LOG_DIR:-/var/log/imapsync}/.heartbeat" && \ + test ! -f "${LOG_DIR:-/var/log/imapsync}/.notification_failed" && \ + test "$(cat "${LOG_DIR:-/var/log/imapsync}/.heartbeat")" -gt "$(date -d '5 minutes ago' +%s)" || \ + { echo "Health check failed: daemon heartbeat is stale or SMTP notification delivery failed. Check container logs."; exit 1; } + +ENTRYPOINT ["/sync.sh"]