From e684c042b176b43b6a2738ecf7a8bc5f6e67e26f Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Mon, 22 Jun 2020 09:22:45 +1200 Subject: [PATCH 01/15] Adds healthz-php to php fpm --- images/php/fpm/Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/images/php/fpm/Dockerfile b/images/php/fpm/Dockerfile index 2473a3a753..b92deaaf4b 100644 --- a/images/php/fpm/Dockerfile +++ b/images/php/fpm/Dockerfile @@ -102,6 +102,19 @@ RUN apk add --no-cache fcgi \ && fix-permissions /app \ && fix-permissions /etc/ssmtp/ssmtp.conf + +# Defining Versions - Composer +# @see https://getcomposer.org/download/ +ENV COMPOSER_VERSION=1.10.7 \ + COMPOSER_HASH_SHA256=b94b872729668de5b5fbf62f16ff588d2a23480dda88c0e45cb43b721b75ae29 + +RUN curl -L -o /tmp/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ + && echo "$COMPOSER_HASH_SHA256 /tmp/composer" | sha256sum \ + && chmod +x /tmp/composer \ + && php -d memory_limit=-1 /tmp/composer create-project amazeeio/healthz-php /healthz-php \ + && rm /tmp/composer + + EXPOSE 9000 ENV AMAZEEIO_DB_HOST=mariadb \ From df581d0de965929908e36e9e96229402fb983aec Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Wed, 24 Jun 2020 11:18:10 +1200 Subject: [PATCH 02/15] Moves healthcheck build into staged build --- images/php/fpm/Dockerfile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/images/php/fpm/Dockerfile b/images/php/fpm/Dockerfile index b92deaaf4b..fb432394ae 100644 --- a/images/php/fpm/Dockerfile +++ b/images/php/fpm/Dockerfile @@ -3,6 +3,21 @@ ARG PHP_IMAGE_VERSION ARG ALPINE_VERSION ARG IMAGE_REPO FROM ${IMAGE_REPO:-lagoon}/commons as commons + +FROM php:${PHP_IMAGE_VERSION}-fpm-alpine${ALPINE_VERSION} as healthcheckbuilder + +# Defining Versions - Composer +# @see https://getcomposer.org/download/ +ENV COMPOSER_VERSION=1.10.7 \ + COMPOSER_HASH_SHA256=b94b872729668de5b5fbf62f16ff588d2a23480dda88c0e45cb43b721b75ae29 + +RUN curl -L -o /tmp/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ + && echo "$COMPOSER_HASH_SHA256 /tmp/composer" | sha256sum \ + && chmod +x /tmp/composer \ + && php -d memory_limit=-1 /tmp/composer create-project amazeeio/healthz-php /healthz-php \ + && rm /tmp/composer + + FROM php:${PHP_IMAGE_VERSION}-fpm-alpine${ALPINE_VERSION} LABEL maintainer="amazee.io" @@ -17,6 +32,10 @@ COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/ COPY --from=commons /sbin/tini /sbin/ COPY --from=commons /home /home +# Copy healthcheck files + +COPY --from=healthcheckbuilder /healthz-php /healthz-php + RUN chmod g+w /etc/passwd \ && mkdir -p /home @@ -102,19 +121,6 @@ RUN apk add --no-cache fcgi \ && fix-permissions /app \ && fix-permissions /etc/ssmtp/ssmtp.conf - -# Defining Versions - Composer -# @see https://getcomposer.org/download/ -ENV COMPOSER_VERSION=1.10.7 \ - COMPOSER_HASH_SHA256=b94b872729668de5b5fbf62f16ff588d2a23480dda88c0e45cb43b721b75ae29 - -RUN curl -L -o /tmp/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ - && echo "$COMPOSER_HASH_SHA256 /tmp/composer" | sha256sum \ - && chmod +x /tmp/composer \ - && php -d memory_limit=-1 /tmp/composer create-project amazeeio/healthz-php /healthz-php \ - && rm /tmp/composer - - EXPOSE 9000 ENV AMAZEEIO_DB_HOST=mariadb \ From e6c1d60a0e1d4e9abbfdfaed50c4d32432e9048b Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Fri, 26 Jun 2020 10:01:19 +1200 Subject: [PATCH 03/15] Adds Luascript healthz fallback --- images/nginx/Dockerfile | 1 + images/nginx/docker-entrypoint | 8 +++++++- images/nginx/healthcheck/README.md | 10 ++++++++++ images/nginx/healthcheck/healthz.locations | 8 ++++++++ images/nginx/healthcheck/healthz.locations.php.disable | 10 ++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 images/nginx/healthcheck/README.md create mode 100644 images/nginx/healthcheck/healthz.locations create mode 100644 images/nginx/healthcheck/healthz.locations.php.disable diff --git a/images/nginx/Dockerfile b/images/nginx/Dockerfile index ceb5c8c1b2..311bf2625f 100644 --- a/images/nginx/Dockerfile +++ b/images/nginx/Dockerfile @@ -36,6 +36,7 @@ COPY fastcgi.conf /etc/nginx/fastcgi_params COPY helpers/ /etc/nginx/helpers/ COPY static-files.conf /etc/nginx/conf.d/app.conf COPY redirects-map.conf /etc/nginx/redirects-map.conf +COPY healthcheck/healthz.locations healthcheck/healthz.locations.php.disable /etc/nginx/conf.d/ RUN mkdir -p /app \ && rm -f /etc/nginx/conf.d/default.conf \ diff --git a/images/nginx/docker-entrypoint b/images/nginx/docker-entrypoint index 602171d227..8130667d12 100755 --- a/images/nginx/docker-entrypoint +++ b/images/nginx/docker-entrypoint @@ -15,8 +15,14 @@ ep /etc/nginx/* # Find all folders within /etc/nginx/conf.d/ find /etc/nginx/conf.d/ -type d | while read DIR; do # envplate if found folder is not empty - if find $DIR -mindepth 1 | read; then + if find $DIR -mindepth 1 | read; then ep $DIR/*; fi done ep /etc/nginx/helpers/* + +# If PHP is enabled, we override the Luascript /healthz check +if [ ! -z "$NGINX_FASTCGI_PASS" ]; then + echo "Setting up Healthz-php:" + mv /etc/nginx/conf.d/healthz.locations.php.disable /etc/nginx/conf.d/healthz.locations +fi diff --git a/images/nginx/healthcheck/README.md b/images/nginx/healthcheck/README.md new file mode 100644 index 0000000000..73109acdcf --- /dev/null +++ b/images/nginx/healthcheck/README.md @@ -0,0 +1,10 @@ +# Healthcheck + +In this directory you'll find two files + +- healthz.locations.php.disable +- healthz.locations + +Both are designed to expose a `/healthz` location from the nginx service. The difference being that the `.php.disable` file is used to point to the [healthz-php](https://github.com/amazeeio/healthz-php) application _if_ there is a PHP service attached to this application. + +The logic for which of the two files are enabled are contained in this image's `docker-entrypoint` file - there we check for the existence of the env var `NGINX_FASTCGI_PASS`, which indicates (or should indicate) the presence of a PHP-fpm service. \ No newline at end of file diff --git a/images/nginx/healthcheck/healthz.locations b/images/nginx/healthcheck/healthz.locations new file mode 100644 index 0000000000..b3bb78d84a --- /dev/null +++ b/images/nginx/healthcheck/healthz.locations @@ -0,0 +1,8 @@ +location /healthz { + content_by_lua_block { + ngx.status = ngx.HTTP_OK; + ngx.header.content_type = 'application/json'; + ngx.say('{"check_nginx":"pass"}'); + ngx.exit(ngx.OK); + } +} \ No newline at end of file diff --git a/images/nginx/healthcheck/healthz.locations.php.disable b/images/nginx/healthcheck/healthz.locations.php.disable new file mode 100644 index 0000000000..04bb045b47 --- /dev/null +++ b/images/nginx/healthcheck/healthz.locations.php.disable @@ -0,0 +1,10 @@ +location /healthz { + rewrite ^/healthz/(.*)$ /healthz/index.php; + + location ~* \.php(/|$) { + include /etc/nginx/fastcgi.conf; + fastcgi_param SCRIPT_NAME /index.php; + fastcgi_param SCRIPT_FILENAME /healthz-php/index.php; + fastcgi_pass ${NGINX_FASTCGI_PASS:-php}:9000; + } +} From b7449be9818e5bda1adaaa2cf768b11c906da6e0 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Mon, 29 Jun 2020 06:02:47 +1200 Subject: [PATCH 04/15] Adds fallback logic for Lua into entrypoint --- images/nginx/Dockerfile | 2 +- images/nginx/docker-entrypoint | 6 +++++- images/nginx/healthcheck/healthz.locations.lua.disable | 8 ++++++++ images/nginx/helpers/90_healthz.conf | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 images/nginx/healthcheck/healthz.locations.lua.disable create mode 100644 images/nginx/helpers/90_healthz.conf diff --git a/images/nginx/Dockerfile b/images/nginx/Dockerfile index 311bf2625f..beed56fdba 100644 --- a/images/nginx/Dockerfile +++ b/images/nginx/Dockerfile @@ -36,7 +36,7 @@ COPY fastcgi.conf /etc/nginx/fastcgi_params COPY helpers/ /etc/nginx/helpers/ COPY static-files.conf /etc/nginx/conf.d/app.conf COPY redirects-map.conf /etc/nginx/redirects-map.conf -COPY healthcheck/healthz.locations healthcheck/healthz.locations.php.disable /etc/nginx/conf.d/ +COPY healthcheck/healthz.locations healthcheck/healthz.locations.php.disable healthcheck/healthz.locations.lua.disable /etc/nginx/conf.d/ RUN mkdir -p /app \ && rm -f /etc/nginx/conf.d/default.conf \ diff --git a/images/nginx/docker-entrypoint b/images/nginx/docker-entrypoint index 8130667d12..448a8fafe0 100755 --- a/images/nginx/docker-entrypoint +++ b/images/nginx/docker-entrypoint @@ -22,7 +22,11 @@ done ep /etc/nginx/helpers/* # If PHP is enabled, we override the Luascript /healthz check +echo "Setting up Healthz routing" if [ ! -z "$NGINX_FASTCGI_PASS" ]; then - echo "Setting up Healthz-php:" + echo "Setting up Healthz routing - using PHP" mv /etc/nginx/conf.d/healthz.locations.php.disable /etc/nginx/conf.d/healthz.locations +else + echo "Setting up Healthz routing - using Lua as fallback" + mv /etc/nginx/conf.d/healthz.locations.lua.disable /etc/nginx/conf.d/healthz.locations fi diff --git a/images/nginx/healthcheck/healthz.locations.lua.disable b/images/nginx/healthcheck/healthz.locations.lua.disable new file mode 100644 index 0000000000..b3bb78d84a --- /dev/null +++ b/images/nginx/healthcheck/healthz.locations.lua.disable @@ -0,0 +1,8 @@ +location /healthz { + content_by_lua_block { + ngx.status = ngx.HTTP_OK; + ngx.header.content_type = 'application/json'; + ngx.say('{"check_nginx":"pass"}'); + ngx.exit(ngx.OK); + } +} \ No newline at end of file diff --git a/images/nginx/helpers/90_healthz.conf b/images/nginx/helpers/90_healthz.conf new file mode 100644 index 0000000000..33356eda06 --- /dev/null +++ b/images/nginx/helpers/90_healthz.conf @@ -0,0 +1 @@ +include /etc/nginx/conf.d/healthz.locations; From acb676e13398b3a920e0c713b99fd814acc94022 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Mon, 29 Jun 2020 06:54:49 +1200 Subject: [PATCH 05/15] Changes base healthcheck directory --- images/nginx/healthcheck/healthz.locations | 4 ++-- images/nginx/healthcheck/healthz.locations.lua.disable | 4 ++-- images/nginx/healthcheck/healthz.locations.php.disable | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/images/nginx/healthcheck/healthz.locations b/images/nginx/healthcheck/healthz.locations index b3bb78d84a..95cf2ed753 100644 --- a/images/nginx/healthcheck/healthz.locations +++ b/images/nginx/healthcheck/healthz.locations @@ -1,8 +1,8 @@ -location /healthz { +location /.lagoonhealthz { content_by_lua_block { ngx.status = ngx.HTTP_OK; ngx.header.content_type = 'application/json'; ngx.say('{"check_nginx":"pass"}'); ngx.exit(ngx.OK); } -} \ No newline at end of file +} diff --git a/images/nginx/healthcheck/healthz.locations.lua.disable b/images/nginx/healthcheck/healthz.locations.lua.disable index b3bb78d84a..95cf2ed753 100644 --- a/images/nginx/healthcheck/healthz.locations.lua.disable +++ b/images/nginx/healthcheck/healthz.locations.lua.disable @@ -1,8 +1,8 @@ -location /healthz { +location /.lagoonhealthz { content_by_lua_block { ngx.status = ngx.HTTP_OK; ngx.header.content_type = 'application/json'; ngx.say('{"check_nginx":"pass"}'); ngx.exit(ngx.OK); } -} \ No newline at end of file +} diff --git a/images/nginx/healthcheck/healthz.locations.php.disable b/images/nginx/healthcheck/healthz.locations.php.disable index 04bb045b47..ba72dc4791 100644 --- a/images/nginx/healthcheck/healthz.locations.php.disable +++ b/images/nginx/healthcheck/healthz.locations.php.disable @@ -1,5 +1,5 @@ -location /healthz { - rewrite ^/healthz/(.*)$ /healthz/index.php; +location /.lagoonhealthz { + rewrite ^/.lagoonhealthz/(.*)$ /healthz/index.php; location ~* \.php(/|$) { include /etc/nginx/fastcgi.conf; From 1d127d075e13b021abfbc963f7bb8b313d9614e9 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Mon, 29 Jun 2020 07:31:04 +1200 Subject: [PATCH 06/15] Changes mv to cp for locations, changes base rewrite for lagoonhealthz --- images/nginx/docker-entrypoint | 4 ++-- images/nginx/healthcheck/healthz.locations.php.disable | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/images/nginx/docker-entrypoint b/images/nginx/docker-entrypoint index 448a8fafe0..2894825d79 100755 --- a/images/nginx/docker-entrypoint +++ b/images/nginx/docker-entrypoint @@ -25,8 +25,8 @@ ep /etc/nginx/helpers/* echo "Setting up Healthz routing" if [ ! -z "$NGINX_FASTCGI_PASS" ]; then echo "Setting up Healthz routing - using PHP" - mv /etc/nginx/conf.d/healthz.locations.php.disable /etc/nginx/conf.d/healthz.locations + cp /etc/nginx/conf.d/healthz.locations.php.disable /etc/nginx/conf.d/healthz.locations else echo "Setting up Healthz routing - using Lua as fallback" - mv /etc/nginx/conf.d/healthz.locations.lua.disable /etc/nginx/conf.d/healthz.locations + cp /etc/nginx/conf.d/healthz.locations.lua.disable /etc/nginx/conf.d/healthz.locations fi diff --git a/images/nginx/healthcheck/healthz.locations.php.disable b/images/nginx/healthcheck/healthz.locations.php.disable index ba72dc4791..f6f5d08bd8 100644 --- a/images/nginx/healthcheck/healthz.locations.php.disable +++ b/images/nginx/healthcheck/healthz.locations.php.disable @@ -1,5 +1,5 @@ location /.lagoonhealthz { - rewrite ^/.lagoonhealthz/(.*)$ /healthz/index.php; + rewrite ^/.lagoonhealthz/(.*)$ /.lagoonhealthz/index.php; location ~* \.php(/|$) { include /etc/nginx/fastcgi.conf; From bf2d0c04c352bfb77fc4de8b2b6bf3a0da6ed5b8 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Mon, 29 Jun 2020 09:41:46 +1200 Subject: [PATCH 07/15] Changes php rewrite rule for healthcheck --- images/nginx/healthcheck/healthz.locations.php.disable | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/nginx/healthcheck/healthz.locations.php.disable b/images/nginx/healthcheck/healthz.locations.php.disable index f6f5d08bd8..8af6022171 100644 --- a/images/nginx/healthcheck/healthz.locations.php.disable +++ b/images/nginx/healthcheck/healthz.locations.php.disable @@ -1,5 +1,5 @@ location /.lagoonhealthz { - rewrite ^/.lagoonhealthz/(.*)$ /.lagoonhealthz/index.php; + rewrite ^/.lagoonhealthz(/.*)$ /.lagoonhealthz/index.php; location ~* \.php(/|$) { include /etc/nginx/fastcgi.conf; From 058906853a6050b1527bbfada7993c6061428b72 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Mon, 29 Jun 2020 10:20:31 +1200 Subject: [PATCH 08/15] Fixes regex on lagoonhealthzphp --- images/nginx/healthcheck/healthz.locations.php.disable | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/nginx/healthcheck/healthz.locations.php.disable b/images/nginx/healthcheck/healthz.locations.php.disable index 8af6022171..dd6be8e7ea 100644 --- a/images/nginx/healthcheck/healthz.locations.php.disable +++ b/images/nginx/healthcheck/healthz.locations.php.disable @@ -1,5 +1,5 @@ location /.lagoonhealthz { - rewrite ^/.lagoonhealthz(/.*)$ /.lagoonhealthz/index.php; + rewrite ^/.lagoonhealthz(/.*)?$ /.lagoonhealthz/index.php; location ~* \.php(/|$) { include /etc/nginx/fastcgi.conf; From f00c48e70bf6f271016d728986e06b269756d4d8 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Tue, 30 Jun 2020 13:31:40 +1200 Subject: [PATCH 09/15] Updates healthz-php version to 0.0.3 --- images/php/fpm/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/php/fpm/Dockerfile b/images/php/fpm/Dockerfile index fb432394ae..cc318751e0 100644 --- a/images/php/fpm/Dockerfile +++ b/images/php/fpm/Dockerfile @@ -14,7 +14,7 @@ ENV COMPOSER_VERSION=1.10.7 \ RUN curl -L -o /tmp/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ && echo "$COMPOSER_HASH_SHA256 /tmp/composer" | sha256sum \ && chmod +x /tmp/composer \ - && php -d memory_limit=-1 /tmp/composer create-project amazeeio/healthz-php /healthz-php \ + && php -d memory_limit=-1 /tmp/composer create-project amazeeio/healthz-php /healthz-php v0.0.3 \ && rm /tmp/composer From 65e2872a42788c3ffed1b59b1527fbeea37b46e0 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Wed, 1 Jul 2020 08:55:53 +1200 Subject: [PATCH 10/15] Adds fast health check (#10) --- images/nginx/docker-entrypoint | 5 +++++ .../helpers/90_healthz_fast_check.conf.disabled | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 images/nginx/helpers/90_healthz_fast_check.conf.disabled diff --git a/images/nginx/docker-entrypoint b/images/nginx/docker-entrypoint index 2894825d79..c7bdac8ae1 100755 --- a/images/nginx/docker-entrypoint +++ b/images/nginx/docker-entrypoint @@ -30,3 +30,8 @@ else echo "Setting up Healthz routing - using Lua as fallback" cp /etc/nginx/conf.d/healthz.locations.lua.disable /etc/nginx/conf.d/healthz.locations fi + +if [ "$FAST_HEALTH_CHECK" == "on" ]; then + echo "FAST HEALTH CHECK ENABLED" + cp /etc/nginx/helpers/90_healthz_fast_check.conf.disabled /etc/nginx/helpers/90_health_fast_check.conf +fi \ No newline at end of file diff --git a/images/nginx/helpers/90_healthz_fast_check.conf.disabled b/images/nginx/helpers/90_healthz_fast_check.conf.disabled new file mode 100644 index 0000000000..78cb43761e --- /dev/null +++ b/images/nginx/helpers/90_healthz_fast_check.conf.disabled @@ -0,0 +1,13 @@ +set $fhcc none; + +if ( $http_user_agent ~* "StatusCake|Pingdom|Site25x7|Uptime|nagios" ) { + set $fhcc "A"; +} + +if ( $request_method = 'GET' ) { + set $fhcc "$fhcc G"; +} + +if ( $fhcc = 'A G' ) { + rewrite ~* /.lagoonhealthz last; +} \ No newline at end of file From 4520bfb8dc3c38c885f7f819c512e2649428691e Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Wed, 1 Jul 2020 09:48:56 +1200 Subject: [PATCH 11/15] Fixes documentation to reflect correct endpoint --- images/nginx/healthcheck/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/nginx/healthcheck/README.md b/images/nginx/healthcheck/README.md index 73109acdcf..43751e2e11 100644 --- a/images/nginx/healthcheck/README.md +++ b/images/nginx/healthcheck/README.md @@ -5,6 +5,6 @@ In this directory you'll find two files - healthz.locations.php.disable - healthz.locations -Both are designed to expose a `/healthz` location from the nginx service. The difference being that the `.php.disable` file is used to point to the [healthz-php](https://github.com/amazeeio/healthz-php) application _if_ there is a PHP service attached to this application. +Both are designed to expose a `/.lagoonhealthz` location from the nginx service. The difference being that the `.php.disable` file is used to point to the [healthz-php](https://github.com/amazeeio/healthz-php) application _if_ there is a PHP service attached to this application. The logic for which of the two files are enabled are contained in this image's `docker-entrypoint` file - there we check for the existence of the env var `NGINX_FASTCGI_PASS`, which indicates (or should indicate) the presence of a PHP-fpm service. \ No newline at end of file From 5c4c5c428942696fb15fd4f242bef9b36199bdc2 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Wed, 1 Jul 2020 10:08:19 +1200 Subject: [PATCH 12/15] Changes health check builder to use the composer image, adds environment variable documentation --- docs/using_lagoon/docker_images/nginx.md | 1 + images/php/fpm/Dockerfile | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/using_lagoon/docker_images/nginx.md b/docs/using_lagoon/docker_images/nginx.md index 24472d9a8b..60850e0233 100644 --- a/docs/using_lagoon/docker_images/nginx.md +++ b/docs/using_lagoon/docker_images/nginx.md @@ -60,3 +60,4 @@ Environment variables are meant to contain common information for the `Nginx` co | `BASIC_AUTH` | `restricted` | By not setting `BASIC_AUTH` this will instruct Lagoon to automatically enable basic authentication if `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` are set. To disable basic authentication even if `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` are set, set `BASIC_AUTH` to `off`. | | `BASIC_AUTH_USERNAME` | \(not set\) | Username for basic authentication | | `BASIC_AUTH_PASSWORD` | \(not set\) | Password for basic authentication \(unencrypted\) | +| `FAST_HEALTH_CHECK` | \(not set\) | If set to `on` this will redirect GET requests from certain user agents (StatusCake, Pingdom, Site25x7, Uptime, nagios) to the lightweight Lagoon service healthcheck. | diff --git a/images/php/fpm/Dockerfile b/images/php/fpm/Dockerfile index cc318751e0..28eec074af 100644 --- a/images/php/fpm/Dockerfile +++ b/images/php/fpm/Dockerfile @@ -4,19 +4,9 @@ ARG ALPINE_VERSION ARG IMAGE_REPO FROM ${IMAGE_REPO:-lagoon}/commons as commons -FROM php:${PHP_IMAGE_VERSION}-fpm-alpine${ALPINE_VERSION} as healthcheckbuilder - -# Defining Versions - Composer -# @see https://getcomposer.org/download/ -ENV COMPOSER_VERSION=1.10.7 \ - COMPOSER_HASH_SHA256=b94b872729668de5b5fbf62f16ff588d2a23480dda88c0e45cb43b721b75ae29 - -RUN curl -L -o /tmp/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ - && echo "$COMPOSER_HASH_SHA256 /tmp/composer" | sha256sum \ - && chmod +x /tmp/composer \ - && php -d memory_limit=-1 /tmp/composer create-project amazeeio/healthz-php /healthz-php v0.0.3 \ - && rm /tmp/composer +FROM composer:latest as healthcheckbuilder +RUN composer create-project --no-dev amazeeio/healthz-php /healthz-php v0.0.3 FROM php:${PHP_IMAGE_VERSION}-fpm-alpine${ALPINE_VERSION} From d4d5ef7e647b823dfb6a34d3d27a893c7a6afcaa Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Fri, 10 Jul 2020 11:20:25 +1200 Subject: [PATCH 13/15] Changes FAST_HEALTH_CHECK flag from 'on' to 'true' --- docs/using_lagoon/docker_images/nginx.md | 2 +- images/nginx/docker-entrypoint | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/using_lagoon/docker_images/nginx.md b/docs/using_lagoon/docker_images/nginx.md index 60850e0233..3f107510b9 100644 --- a/docs/using_lagoon/docker_images/nginx.md +++ b/docs/using_lagoon/docker_images/nginx.md @@ -60,4 +60,4 @@ Environment variables are meant to contain common information for the `Nginx` co | `BASIC_AUTH` | `restricted` | By not setting `BASIC_AUTH` this will instruct Lagoon to automatically enable basic authentication if `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` are set. To disable basic authentication even if `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` are set, set `BASIC_AUTH` to `off`. | | `BASIC_AUTH_USERNAME` | \(not set\) | Username for basic authentication | | `BASIC_AUTH_PASSWORD` | \(not set\) | Password for basic authentication \(unencrypted\) | -| `FAST_HEALTH_CHECK` | \(not set\) | If set to `on` this will redirect GET requests from certain user agents (StatusCake, Pingdom, Site25x7, Uptime, nagios) to the lightweight Lagoon service healthcheck. | +| `FAST_HEALTH_CHECK` | \(not set\) | If set to `true` this will redirect GET requests from certain user agents (StatusCake, Pingdom, Site25x7, Uptime, nagios) to the lightweight Lagoon service healthcheck. | diff --git a/images/nginx/docker-entrypoint b/images/nginx/docker-entrypoint index c7bdac8ae1..ebef6d365d 100755 --- a/images/nginx/docker-entrypoint +++ b/images/nginx/docker-entrypoint @@ -31,7 +31,7 @@ else cp /etc/nginx/conf.d/healthz.locations.lua.disable /etc/nginx/conf.d/healthz.locations fi -if [ "$FAST_HEALTH_CHECK" == "on" ]; then +if [ "$FAST_HEALTH_CHECK" == "true" ]; then echo "FAST HEALTH CHECK ENABLED" cp /etc/nginx/helpers/90_healthz_fast_check.conf.disabled /etc/nginx/helpers/90_health_fast_check.conf fi \ No newline at end of file From 47943a1821d7d97b6d67e64dc30bf193aff70388 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Fri, 10 Jul 2020 13:55:54 +1200 Subject: [PATCH 14/15] Removes the redundant step of overwriting the lua healthcheck default with a duplicate lua file --- images/nginx/docker-entrypoint | 5 +---- images/nginx/healthcheck/healthz.locations.lua.disable | 8 -------- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 images/nginx/healthcheck/healthz.locations.lua.disable diff --git a/images/nginx/docker-entrypoint b/images/nginx/docker-entrypoint index ebef6d365d..2f8458ec4a 100755 --- a/images/nginx/docker-entrypoint +++ b/images/nginx/docker-entrypoint @@ -24,11 +24,8 @@ ep /etc/nginx/helpers/* # If PHP is enabled, we override the Luascript /healthz check echo "Setting up Healthz routing" if [ ! -z "$NGINX_FASTCGI_PASS" ]; then - echo "Setting up Healthz routing - using PHP" + echo "Healthz routing - using PHP" cp /etc/nginx/conf.d/healthz.locations.php.disable /etc/nginx/conf.d/healthz.locations -else - echo "Setting up Healthz routing - using Lua as fallback" - cp /etc/nginx/conf.d/healthz.locations.lua.disable /etc/nginx/conf.d/healthz.locations fi if [ "$FAST_HEALTH_CHECK" == "true" ]; then diff --git a/images/nginx/healthcheck/healthz.locations.lua.disable b/images/nginx/healthcheck/healthz.locations.lua.disable deleted file mode 100644 index 95cf2ed753..0000000000 --- a/images/nginx/healthcheck/healthz.locations.lua.disable +++ /dev/null @@ -1,8 +0,0 @@ -location /.lagoonhealthz { - content_by_lua_block { - ngx.status = ngx.HTTP_OK; - ngx.header.content_type = 'application/json'; - ngx.say('{"check_nginx":"pass"}'); - ngx.exit(ngx.OK); - } -} From 47083ce1aff8e1b4806993b9e03096fdf61b8ba4 Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Fri, 10 Jul 2020 14:02:56 +1200 Subject: [PATCH 15/15] Removed reference to healthcheck lua file in dockerfile --- images/nginx/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/nginx/Dockerfile b/images/nginx/Dockerfile index beed56fdba..311bf2625f 100644 --- a/images/nginx/Dockerfile +++ b/images/nginx/Dockerfile @@ -36,7 +36,7 @@ COPY fastcgi.conf /etc/nginx/fastcgi_params COPY helpers/ /etc/nginx/helpers/ COPY static-files.conf /etc/nginx/conf.d/app.conf COPY redirects-map.conf /etc/nginx/redirects-map.conf -COPY healthcheck/healthz.locations healthcheck/healthz.locations.php.disable healthcheck/healthz.locations.lua.disable /etc/nginx/conf.d/ +COPY healthcheck/healthz.locations healthcheck/healthz.locations.php.disable /etc/nginx/conf.d/ RUN mkdir -p /app \ && rm -f /etc/nginx/conf.d/default.conf \