diff --git a/nginx/Dockerfile b/nginx/Dockerfile index d269829..d69e484 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -38,3 +38,7 @@ ENV TZ=Etc/UTC COPY etc/ /etc WORKDIR /var/www/html + +# Healthcheck +HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ + CMD ["curl", "--fail", "http://localhost/healthcheck"] diff --git a/nginx/etc/nginx/templates/default.conf.template b/nginx/etc/nginx/templates/default.conf.template index b1ea91a..01a5d97 100644 --- a/nginx/etc/nginx/templates/default.conf.template +++ b/nginx/etc/nginx/templates/default.conf.template @@ -32,6 +32,12 @@ server { server_name ${NGINX_HOST} index index.php index.htm; + location /healthcheck { + access_log off; + error_log off; + return 200 'ok'; + } + location ~ \.php$ { include fastcgi_params; fastcgi_pass ${PHP_HOST}:9000; @@ -39,10 +45,17 @@ server { fastcgi_param REQUEST_METHOD $request_method; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; } + + location /status { + include fastcgi_params; + fastcgi_pass ${PHP_HOST}:9000; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + } location / { - #try_files $uri $uri/ /index.php?$query_string =404; - rewrite ^ index.php last; + try_files $uri $uri/ /index.php?$query_string =404; + #rewrite ^ index.php last; } } \ No newline at end of file diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index ffde2cc..7f66a04 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -41,10 +41,13 @@ COPY etc/php /usr/local/etc/php/conf.d # Install dependencies RUN apk update && \ apk upgrade && \ - apk add git && \ + apk add git fcgi && \ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer && \ rm -rf /var/cache/apk/* +# Enable php fpm status page +RUN set -xe && echo "pm.status_path = /status" >> /usr/local/etc/php-fpm.d/zz-docker.conf + # Install and execute own entrypoint script. This scrpit should hold all instructions that are not # executed while the image is build (use RUN in this file therefore) but that are run when the # container starts up. One major advanatge is that mounted volumes are already available when this