From 9a12b5c3c66a0d986cb1687e4a6fdc50e60780a4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 2 Jun 2024 18:26:59 +0200 Subject: [PATCH] added health check The check runs the standard DokuWiki initialization, fatal errors should get caught and be reported back to docker --- Dockerfile | 3 +++ README.md | 1 + root/var/www/html/health.php | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 root/var/www/html/health.php diff --git a/Dockerfile b/Dockerfile index 53ad640..bd619ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,5 +18,8 @@ RUN /bin/bash /build-setup.sh VOLUME /storage EXPOSE 8080 +HEALTHCHECK --timeout=5s \ + CMD curl --silent --fail-with-body http://localhost:8080/health.php || exit 1 + RUN chmod +x /dokuwiki-entrypoint.sh ENTRYPOINT ["/dokuwiki-entrypoint.sh"] diff --git a/README.md b/README.md index ba9ada0..f55f705 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ On first run, use DokuWiki's [installer](https://www.dokuwiki.org/installer) to * imagemagick installed and enabled * nice URLs via rewriting configured and enabled * farming support via the [farmer plugin](https://www.dokuwiki.org/plugin:farmer) +* docker health check running basic DokuWiki checks (every 30 seconds, 3 retries) Note: This image does **not** include a mail server. You need to configure DokuWiki to use an external mail server, this is most easily achieved using the [SMTP plugin](https://www.dokuwiki.org/plugin:smtp). diff --git a/root/var/www/html/health.php b/root/var/www/html/health.php new file mode 100644 index 0000000..3e749d4 --- /dev/null +++ b/root/var/www/html/health.php @@ -0,0 +1,25 @@ +getMessage(); + $msg = strip_tags($msg); + $msg = preg_replace('/^nice_die:/', '', $msg); + $msg = preg_replace('/\s+/', ' ', $msg); + $msg = trim($msg); + echo $msg; +} +