Support STACK_NAME / PHP_SERVICE..
continuous-integration/drone/push Build is passing Details

..so it continues to work on both local and remote
This commit is contained in:
3wc 2021-12-21 12:11:40 +02:00
parent fd6359fe72
commit ebd47a4bb5
4 changed files with 25 additions and 3 deletions

View File

@ -1,4 +1,17 @@
FROM nginx:1.21.4
# TODO: use renovate-bot to send pull requests on upstream image updates
COPY nginx.conf /etc/nginx/templates/default.conf.template
RUN mkdir /etc/nginx/templates.override
COPY nginx.conf /etc/nginx/templates.override/default.conf.template
# goenvtemplator2 for config file updates, working around msmtp's inability to
# configure itself from environment variables.
# nginx includes gettext's envsubst, which is generall is more common, but it
# doesn't support conditionals, or even the "default" syntax ${FOO:+default}
ADD https://github.com/seznam/goenvtemplator/releases/download/v2.0.0/goenvtemplator2-amd64 /usr/local/bin/goenvtemplator2
RUN chmod +x /usr/local/bin/goenvtemplator2
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -4,7 +4,7 @@
A very lightly-customised `nginx` Docker image, featuring:
* A Wordpress / PHP-FPM configuration file
* A Wordpress / PHP-FPM configuration file template for Nginx
Changes to this repository are automatically published to [Docker
Hub](https://hub.docker.com/r/thecoopcloud/nginx) as

5
entrypoint.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
goenvtemplator2 -template /etc/nginx/templates.override/default.conf.template:/etc/nginx/conf.d/default.conf
/docker-entrypoint.sh "$@"

View File

@ -30,7 +30,11 @@ server {
location ~ .php$ {
fastcgi_read_timeout 300;
fastcgi_pass ${STACK_NAME}_php:9000;
{{ if not (eq (env "PHP_SERVICE") "") }}
fastcgi_pass {{ env "PHP_SERVICE" }}:9000;
{{ else }}
fastcgi_pass {{ env "STACK_NAME" }}_php:9000;
{{ end }}
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /app/web/$fastcgi_script_name;