-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathdocker-compose.prod.yaml
More file actions
141 lines (135 loc) · 3.74 KB
/
Copy pathdocker-compose.prod.yaml
File metadata and controls
141 lines (135 loc) · 3.74 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
x-backend-base: &backend-base
build:
context: backend
target: prod
cap_drop:
- all
cap_add:
- setuid
- setgid
- setfcap
env_file:
- docker.prod.env
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8000/api/healthz"]
interval: 15s
timeout: 3s
retries: 10
start_period: 20s
security_opt:
- apparmor=unconfined
- seccomp=unconfined
volumes:
# persist compilers + libraries
- ./backend/compilers:/backend/compilers
- ./backend/libraries:/backend/libraries
# static files for django /admin control panel
- ./backend/static:/backend/static
tmpfs:
# Use a separate tmpfs to prevent a rogue jailed process
# from filling /tmp on the parent container
- /sandbox/tmp:exec,uid=1000,gid=1000,size=64M,mode=0700
networks:
- decompme
x-frontend-base: &frontend-base
build:
context: frontend
target: prod
env_file:
- docker.prod.env
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/healthz"]
interval: 15s
timeout: 3s
retries: 10
start_period: 20s
networks:
- decompme
services:
backend-blue:
<<: *backend-base
image: ghcr.io/decompme/decompme-backend:${BLUE_TAG:-latest}
frontend-blue:
<<: *frontend-base
image: ghcr.io/decompme/decompme-frontend:${BLUE_TAG:-latest}
environment:
INTERNAL_API_BASE: http://backend-blue:8000/api
backend-green:
<<: *backend-base
image: ghcr.io/decompme/decompme-backend:${GREEN_TAG:-latest}
frontend-green:
<<: *frontend-base
image: ghcr.io/decompme/decompme-frontend:${GREEN_TAG:-latest}
environment:
INTERNAL_API_BASE: http://backend-green:8000/api
nginx:
image: ghcr.io/decompme/decompme-nginx:${NGINX_TAG:-latest}
build:
context: nginx
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1/nginx-healthz"]
interval: 15s
timeout: 3s
retries: 10
start_period: 5s
ports:
- "80:80"
- "443:443"
restart: unless-stopped
volumes:
# repo files
- ./nginx/production/:/etc/nginx/conf.d/:ro
- ./frontend/down.html:/var/www/decomp.me/down.html:ro
# certbot
- ./certbot:/var/www/certbot
- ./letsencrypt:/etc/letsencrypt
# NOTE: /media is a "Project" feature, currently unused
- ./backend/media:/media
# static files for django /admin control panel
- ./backend/static:/var/www/decomp.me/static
# TODO: mount static + public files from frontend
# BOOTSTRAP: allow nginx to start before backend/frontend containers are up
#extra_hosts:
# - "backend-blue=172.17.0.1" # docker0 bridge
# - "frontend-blue=172.17.0.1" # docker0 bridge
networks:
- decompme
certbot:
image: certbot/certbot
restart: unless-stopped
volumes:
- ./certbot:/var/www/certbot
- ./letsencrypt:/etc/letsencrypt
entrypoint: "/bin/sh -c"
command: >
"trap exit TERM; while :; do sleep 12h & wait $${!}; certbot renew --webroot -w /var/www/certbot; done"
networks:
- decompme
postgres:
image: postgres:17
env_file:
- docker.prod.env
# ports:
# - "5432:5432"
restart: unless-stopped
volumes:
- ./postgres:/var/lib/postgresql/data
# BOOTSTRAP: for dumping/restoring db
- ./pgdump:/pgdump
networks:
- decompme
command: >
postgres
-c shared_buffers=8GB
-c work_mem=128MB
-c maintenance_work_mem=2GB
-c effective_cache_size=16GB
-c wal_buffers=32MB
-c checkpoint_completion_target=0.9
-c random_page_cost=1.1
-c effective_io_concurrency=300
networks:
decompme:
driver: bridge