From 39d39915e464041792909d4c1d590f7cf45366d3 Mon Sep 17 00:00:00 2001 From: "g.nardiello" Date: Thu, 5 Jan 2023 11:55:04 +0100 Subject: [PATCH] Added file-based HEALTHCHECK --- Dockerfile | 5 ++++- run.sh | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c06ccf7..fdfa250 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,4 +41,7 @@ RUN mkdir /backup && \ VOLUME ["/backup"] -CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh +HEALTHCHECK --interval=2s --retries=1800 \ + CMD stat /HEALTLY.status || exit 1 + +ENTRYPOINT dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh \ No newline at end of file diff --git a/run.sh b/run.sh index 95f8009..862a566 100755 --- a/run.sh +++ b/run.sh @@ -14,6 +14,8 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh fi +touch /HEALTLY.status + echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf crontab /tmp/crontab.conf echo "=> Running cron task manager in foreground"