-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
364 lines (353 loc) · 10.3 KB
/
docker-compose.prod.yml
File metadata and controls
364 lines (353 loc) · 10.3 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# APIbase.pro — Docker Compose Production Overlay (§12.194)
# 10 monitoring/ops containers. Extends docker-compose.yml (6 base containers).
# Usage: docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
services:
# ---------------------------------------------------------------------------
# prometheus — Metrics TSDB (§12.194, §12.197, §12.245 port 9090)
# ---------------------------------------------------------------------------
prometheus:
image: prom/prometheus:v2.51.0
restart: unless-stopped
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention.time=15d"
- "--web.enable-lifecycle"
ports:
- "127.0.0.1:9090:9090"
volumes:
- prometheus_data:/prometheus
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./prometheus/rules:/etc/prometheus/rules:ro
depends_on:
api:
condition: service_healthy
networks:
- app
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1:9090/-/healthy || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
deploy:
resources:
limits:
memory: 2G
cpus: "1.0"
cap_drop:
- ALL
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# grafana — Dashboards (§12.194, §12.206, §12.245 port 3000)
# ---------------------------------------------------------------------------
grafana:
image: grafana/grafana:10.4.0
restart: unless-stopped
ports:
- "127.0.0.1:3940:3000"
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: ${GF_ADMIN_PASSWORD:?GF_ADMIN_PASSWORD required}
GF_AUTH_ANONYMOUS_ENABLED: "false"
GF_SERVER_ROOT_URL: "http://localhost:3940"
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro
depends_on:
prometheus:
condition: service_healthy
loki:
condition: service_healthy
networks:
- app
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1:3000/api/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
memory: 1G
cpus: "0.5"
cap_drop:
- ALL
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# loki — Log aggregation (§12.194, §12.197, §12.245 port 3100)
# ---------------------------------------------------------------------------
loki:
image: grafana/loki:2.9.0
restart: unless-stopped
command: ["-config.file=/etc/loki/local-config.yaml"]
user: "0:0"
volumes:
- loki_data:/loki
- ./loki/config.yml:/etc/loki/local-config.yaml:ro
networks:
- app
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1:3100/ready || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
deploy:
resources:
limits:
memory: 2G
cpus: "1.0"
cap_drop:
- ALL
cap_add:
- CHOWN
- DAC_OVERRIDE
tmpfs:
- /tmp
- /wal
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# promtail — Log collection (§12.194, §12.197, §12.245 port 9080)
# ---------------------------------------------------------------------------
promtail:
image: grafana/promtail:2.9.0
restart: unless-stopped
command: ["-config.file=/etc/promtail/config.yml"]
volumes:
- ./promtail/config.yml:/etc/promtail/config.yml:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
loki:
condition: service_healthy
networks:
- app
healthcheck:
test: ["CMD-SHELL", "echo OK"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
deploy:
resources:
limits:
memory: 512M
cpus: "0.25"
cap_drop:
- ALL
cap_add:
- DAC_READ_SEARCH
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# alertmanager — Alert routing (§12.194, §12.207, §12.245 port 9093)
# ---------------------------------------------------------------------------
alertmanager:
image: prom/alertmanager:v0.27.0
restart: unless-stopped
command:
- "--config.file=/etc/alertmanager/alertmanager.yml"
volumes:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
networks:
- app
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1:9093/-/healthy || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
deploy:
resources:
limits:
memory: 512M
cpus: "0.25"
read_only: true
cap_drop:
- ALL
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# postgres_exporter — PG metrics (§12.194, §12.205, §12.245 port 9187)
# ---------------------------------------------------------------------------
postgres_exporter:
image: quay.io/prometheuscommunity/postgres-exporter:v0.15.0
restart: unless-stopped
environment:
DATA_SOURCE_NAME: "postgresql://${POSTGRES_USER:-apibase}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-apibase}?sslmode=disable"
depends_on:
postgres:
condition: service_healthy
networks:
- app
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1:9187/metrics || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
deploy:
resources:
limits:
memory: 128M
cpus: "0.1"
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# redis_exporter — Redis metrics (§12.194, §12.210, §12.245 port 9121)
# ---------------------------------------------------------------------------
redis_exporter:
image: oliver006/redis_exporter:v1.58.0
restart: unless-stopped
environment:
REDIS_ADDR: "redis://redis:6379"
depends_on:
redis:
condition: service_healthy
networks:
- app
healthcheck:
test: ["CMD", "/redis_exporter", "--version"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 128M
cpus: "0.1"
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# nginx_exporter — Nginx metrics (§12.194, §12.245 port 9113)
# ---------------------------------------------------------------------------
nginx_exporter:
image: nginx/nginx-prometheus-exporter:1.1.0
restart: unless-stopped
command: ["--nginx.scrape-uri=http://nginx:8080/stub_status"]
depends_on:
nginx:
condition: service_healthy
networks:
- app
healthcheck:
test: ["CMD", "/usr/bin/nginx-prometheus-exporter", "--version"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 64M
cpus: "0.1"
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# postgres_backup — Daily PG backup (§12.194, §12.245 port 8080)
# ---------------------------------------------------------------------------
postgres_backup:
image: prodrigestivill/postgres-backup-local:16
restart: unless-stopped
environment:
POSTGRES_HOST: postgres
POSTGRES_DB: ${POSTGRES_DB:-apibase}
POSTGRES_USER: ${POSTGRES_USER:-apibase}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
SCHEDULE: "0 3 * * *"
BACKUP_KEEP_DAYS: "7"
BACKUP_KEEP_WEEKS: "4"
BACKUP_KEEP_MONTHS: "6"
HEALTHCHECK_PORT: "8080"
volumes:
- ./backups:/backups
depends_on:
postgres:
condition: service_healthy
networks:
- app
healthcheck:
test: ["CMD-SHELL", "curl -sf http://127.0.0.1:8080/ || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 512M
cpus: "0.25"
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# node_exporter — Host metrics (§12.194, §12.245 port 9100)
# ---------------------------------------------------------------------------
node_exporter:
image: prom/node-exporter:v1.7.0
restart: unless-stopped
command:
- "--path.rootfs=/host"
- "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
volumes:
- /:/host:ro,rslave
networks:
- app
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1:9100/metrics || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
deploy:
resources:
limits:
memory: 128M
cpus: "0.1"
read_only: true
cap_drop:
- ALL
cap_add:
- SYS_TIME
security_opt:
- no-new-privileges:true
stop_grace_period: 10s
# ---------------------------------------------------------------------------
# Volumes — named only (§12.203)
# ---------------------------------------------------------------------------
volumes:
prometheus_data:
grafana_data:
loki_data: