-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdocker-compose.prod.yml
49 lines (47 loc) · 1.37 KB
/
docker-compose.prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
version: "3.7"
services:
# Build dynamic configuration for nginx
nginx_template:
image: nginx:latest
container_name: ${PROJ_NAME}_nginx_template
env_file: .env
entrypoint: /bin/bash -c "envsubst '$$HOST_NAME' < /etc/nginx/conf.d/site.template > /etc/nginx/conf.d/site.conf"
volumes:
- ./nginx/conf:/etc/nginx/conf.d
networks:
- backend
# Web server/proxy
nginx:
image: nginx:latest
container_name: ${PROJ_NAME}_nginx
env_file: .env
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
deploy:
replicas: 1
restart_policy:
condition: on-failure
ports:
- "443:443"
- "80:80"
volumes:
- ./logs/nginx:/tmp/logs
- ./static:/opt/app/static
- ./media:/opt/app/media
- ./nginx/run.sh:/opt/run.sh
- ./nginx/conf:/etc/nginx/conf.d
- ./nginx/certbot/conf:/etc/letsencrypt
- ./nginx/certbot/www:/var/www/certbot
networks:
- backend
links:
- backend
depends_on:
- backend
- nginx_template
# Generate certificate with letsencrypt
certbot:
image: certbot/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
volumes:
- ./nginx/certbot/conf:/etc/letsencrypt
- ./nginx/certbot/www:/var/www/certbot