Skip to content

Commit

Permalink
Make php-fpm server name an env var (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall authored Jun 30, 2023
1 parent 420307e commit 17c62ba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 6 additions & 3 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ http {
fastcgi_read_timeout 600;

upstream php_fpm_service {
server php-fpm:9000;
server ${PHP_FPM_HOST}:9000;
}

server {
Expand Down
11 changes: 11 additions & 0 deletions nginx/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 17c62ba

Please sign in to comment.