Skip to content

Commit

Permalink
moved nginx config modification to docker via command with envsubst
Browse files Browse the repository at this point in the history
  • Loading branch information
Cielquan committed Nov 16, 2019
1 parent 199946c commit 4848143
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions docker-compose.nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ services:
nginx:
container_name: nginx
hostname: ${HOST_NAME}
image: nginx:v1.17
image: nginx:1.17
environment:
- DOMAIN=${DOMAIN}
volumes:
- ./nginx-docker/configs/:/etc/nginx/
- ./nginx-docker/templates/:/etc/nginx/templates/
- ./certificates/certs/:/etc/ssl/certs/
- ./certificates/private/:/etc/ssl/private/
- ./certificates/dhparam.pem:/etc/nginx/dhparam.pem
Expand All @@ -20,4 +23,10 @@ services:
networks:
dns_network0:
ipv4_address: 172.16.1.2
restart: always
restart: always
command: >-
/bin/bash -c
"envsubst < /etc/nginx/templates/cert_DOMAIN.conf.template > /etc/nginx/snippets/cert_${DOMAIN}.conf &&
envsubst < /etc/nginx/templates/dns-over-tls.conf.template > /etc/nginx/streams/dns-over-tls.conf &&
envsubst < /etc/nginx/templates/DOMAIN.conf.template > /etc/nginx/sites-enabled/${DOMAIN}.conf &&
nginx -g 'daemon off;'"
9 changes: 9 additions & 0 deletions docker-compose.traefik.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ services:
container_name: nginx
hostname: ${HOST_NAME}
image: nginx:1.17
environment:
- DOMAIN=${DOMAIN}
volumes:
- ./nginx-docker/configs/:/etc/nginx/
- ./nginx-docker/templates/:/etc/nginx/templates/
- ./certificates/certs/:/etc/ssl/certs/
- ./certificates/private/:/etc/ssl/private/
- ./certificates/dhparam.pem:/etc/nginx/dhparam.pem
Expand All @@ -33,6 +36,12 @@ services:
traefik_proxy:
ipv4_address: 172.16.0.2
restart: always
command: >-
/bin/bash -c
"envsubst < /etc/nginx/templates/cert_DOMAIN.conf.template > /etc/nginx/snippets/cert_${DOMAIN}.conf &&
envsubst < /etc/nginx/templates/dns-over-tls.conf.template > /etc/nginx/streams/dns-over-tls.conf &&
envsubst < /etc/nginx/templates/DOMAIN.conf.template > /etc/nginx/sites-enabled/${DOMAIN}.conf &&
nginx -g 'daemon off;'"
labels:
- traefik.enable=true
- traefik.docker.network=traefik_proxy
Expand Down

0 comments on commit 4848143

Please sign in to comment.