diff --git a/nginx/Dockerfile b/nginx/Dockerfile index e502bb6..8488214 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,9 +1,12 @@ ARG NGINX_VERSION=1.25.1 - FROM nginx:${NGINX_VERSION} +ENV PHP_FPM_HOST=php-fpm + COPY conf/fastcgi_params /etc/nginx/fastcgi_params -COPY conf/nginx.conf /etc/nginx/nginx.conf +COPY conf/nginx.conf /etc/nginx/nginx.conf.template + +COPY docker-entrypoint.sh / RUN rm /docker-entrypoint.d/* /etc/nginx/conf.d/*.conf && \ - mkdir -p /code/web + chmod +x /docker-entrypoint.sh diff --git a/nginx/conf/nginx.conf b/nginx/conf/nginx.conf index 48ee19b..c2a5c47 100644 --- a/nginx/conf/nginx.conf +++ b/nginx/conf/nginx.conf @@ -25,7 +25,7 @@ http { fastcgi_read_timeout 600; upstream php_fpm_service { - server php-fpm:9000; + server ${PHP_FPM_HOST}:9000; } server { diff --git a/nginx/docker-entrypoint.sh b/nginx/docker-entrypoint.sh new file mode 100644 index 0000000..b4e5cf3 --- /dev/null +++ b/nginx/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/env bash + +set -e + +envsubst '${PHP_FPM_HOST}' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf + +if [[ "$1" == -* ]]; then + set -- nginx -g daemon off; "$@" +fi + +exec "$@"