From 19c260b8da3a864c95a8ebb05765fd6134ad7104 Mon Sep 17 00:00:00 2001 From: moritz Date: Thu, 12 Jan 2023 21:16:31 +0000 Subject: [PATCH] healthchecks (#32) Adding healthchecks for nginx, mariadb, redis and php-fpm Co-authored-by: Moritz Reviewed-on: https://git.coopcloud.tech/coop-cloud/nextcloud/pulls/32 --- compose.mariadb.yml | 6 ++++++ compose.yml | 17 +++++++++++++++++ entrypoint.sh.tmpl | 2 ++ 3 files changed, 25 insertions(+) diff --git a/compose.mariadb.yml b/compose.mariadb.yml index 956e424..d7ddaac 100644 --- a/compose.mariadb.yml +++ b/compose.mariadb.yml @@ -31,6 +31,12 @@ services: backupbot.backup.pre-hook: 'mkdir -p /tmp/backup/ && mysqldump --single-transaction -u root -p"$$(cat /run/secrets/db_root_password)" nextcloud > /tmp/backup/backup.sql' backupbot.backup.post-hook: "rm -rf /tmp/backup" backupbot.backup.path: "/tmp/backup/" + healthcheck: + test: ["CMD-SHELL", 'mysqladmin -p"$$(cat /run/secrets/db_root_password)" ping'] + interval: 30s + timeout: 10s + retries: 10 + start_period: 1m configs: my_tune: name: ${STACK_NAME}_my_cnf_${MY_CNF_VERSION} diff --git a/compose.yml b/compose.yml index 341ffd1..df9d279 100644 --- a/compose.yml +++ b/compose.yml @@ -33,6 +33,12 @@ services: - "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect" - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true" - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" + healthcheck: + test: ["CMD-SHELL", 'curl -s -N curl -Ns localhost/status.php | grep "installed\":true"'] + interval: 30s + timeout: 10s + retries: 10 + start_period: 1m app: image: nextcloud:25.0.1-fpm @@ -83,6 +89,12 @@ services: - "coop-cloud.${STACK_NAME}.version=3.0.1+25.0.1-fpm" - "backupbot.backup=true" - "backupbot.backup.path=/var/www/html/config/,/var/www/html/data/,/var/www/html/custom_apps/" + healthcheck: + test: ["CMD-SHELL", 'SCRIPT_NAME=status SCRIPT_FILENAME=/var/www/html/status.php REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 | grep "installed\":true"'] + interval: 30s + timeout: 10s + retries: 10 + start_period: 1m cron: image: nextcloud:25.0.1-fpm @@ -102,6 +114,11 @@ services: - internal volumes: - "redis:/data" + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 3s + timeout: 5s + retries: 20 secrets: db_root_password: diff --git a/entrypoint.sh.tmpl b/entrypoint.sh.tmpl index 742ccb9..c2e5ab6 100644 --- a/entrypoint.sh.tmpl +++ b/entrypoint.sh.tmpl @@ -34,6 +34,8 @@ if ! [[ $(grep {{ env "X_FRAME_OPTIONS_ALLOW_FROM" }} lib/public/AppFramework/Ht fi {{ end }} +# Required for healthcheck +which cgi-fcgi > /dev/null || (apt-get update && apt-get install -y libfcgi-bin) /entrypoint.sh php-fpm