Made the upstream host/port a environment variable

migrate-github-actions
Tim de Pater 2016-02-18 11:40:48 +01:00
parent e9ed481eaa
commit fd5b5c096e
3 changed files with 10 additions and 1 deletions

View File

@ -14,3 +14,6 @@ nginx:
- appdata
ports:
- 80:80
environment:
- UPSTREAM_HOST=fpm
- UPSTREAM_PORT=9000

View File

@ -1,3 +1,9 @@
FROM nginx:1.9
COPY nginx.conf /etc/nginx/conf.d/app.conf
CMD /bin/bash -c envsubst < /etc/nginx/conf.d/app.conf.template > /etc/nginx/conf.d/app.conf && nginx -g 'daemon off;'
CMD sed -i 's/UPSTREAM_HOST/'"$UPSTREAM_HOST"'/g' /etc/nginx/conf.d/app.conf \
&& sed -i 's/UPSTREAM_PORT/'"$UPSTREAM_PORT"'/g' /etc/nginx/conf.d/app.conf \
&& nginx -g 'daemon off;'

View File

@ -36,7 +36,7 @@ server {
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass fpm:9000;
fastcgi_pass UPSTREAM_HOST:UPSTREAM_PORT;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;