From f73e6ce132d0255a9ad7d87e28afb2f3d38001a6 Mon Sep 17 00:00:00 2001 From: Arthur de Moulins Date: Wed, 27 Nov 2024 22:54:17 +0100 Subject: [PATCH] add healthcheck to containers --- infra/docker/nginx-client-base/Dockerfile | 3 +++ infra/docker/nginx-fpm-base/Dockerfile | 3 +++ infra/docker/php-fpm-base/Dockerfile | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/infra/docker/nginx-client-base/Dockerfile b/infra/docker/nginx-client-base/Dockerfile index 65cdba545..889357010 100644 --- a/infra/docker/nginx-client-base/Dockerfile +++ b/infra/docker/nginx-client-base/Dockerfile @@ -22,3 +22,6 @@ WORKDIR /var/app ENTRYPOINT ["/entrypoint.sh"] CMD ["nginx", "-g", "daemon off;"] + +HEALTHCHECK --start-interval=1s --start-period=30s --retries=60 --interval=60s \ + CMD wget -O /dev/null http://127.0.0.1/index.html?healthcheck || exit 1 diff --git a/infra/docker/nginx-fpm-base/Dockerfile b/infra/docker/nginx-fpm-base/Dockerfile index 718add5b6..209998dd1 100644 --- a/infra/docker/nginx-fpm-base/Dockerfile +++ b/infra/docker/nginx-fpm-base/Dockerfile @@ -8,6 +8,9 @@ COPY tpl /etc/nginx/tpl ENTRYPOINT ["/entrypoint.sh"] CMD ["nginx", "-g", "daemon off;"] +HEALTHCHECK --start-interval=1s --start-period=20s --retries=20 --interval=60s \ + CMD wget -O /dev/null http://127.0.0.1/favicon.ico?healthcheck || exit 1 + ENV UPLOAD_MAX_FILE_SIZE=5M EXPOSE 80 diff --git a/infra/docker/php-fpm-base/Dockerfile b/infra/docker/php-fpm-base/Dockerfile index 1b0010549..c3a85b868 100644 --- a/infra/docker/php-fpm-base/Dockerfile +++ b/infra/docker/php-fpm-base/Dockerfile @@ -71,10 +71,16 @@ RUN ln -s $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini \ # Increase process-timeout for "composer test" which downloads phpunit && composer config --global process-timeout 2000 \ && adduser -D -u 1000 app \ - && printf "\nuser = app\ngroup = app\n" >> /usr/local/etc/php-fpm.d/zz-docker.conf + && printf "\nuser = app\ngroup = app\n" >> /usr/local/etc/php-fpm.d/zz-docker.conf \ + && wget -O /usr/local/bin/php-fpm-healthcheck https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/v0.5.0/php-fpm-healthcheck \ + && chmod +x /usr/local/bin/php-fpm-healthcheck \ + && printf "pm.status_path = /status\n" >> /usr/local/etc/php-fpm.d/zz-docker.conf WORKDIR /srv/app RUN chown -R app:app . CMD ["true"] + +HEALTHCHECK --start-interval=2s --start-period=30s --retries=50 --interval=60s --timeout=3s \ + CMD php-fpm-healthcheck || exit 1