-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
537 lines (505 loc) · 16.7 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
537 lines (505 loc) · 16.7 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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
###############################################################
# docker-compose.prod.yml — Production hardening overlay
#
# Usage: docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
#
# Changes from dev compose:
# - Removes all exposed ports (except gateway:8222 and grafana:3000)
# - Adds resource limits per container type
# - Adds log rotation (json-file, max 10m, 3 files)
# - Sets restart: unless-stopped for all services
# - Adds read_only + tmpfs for stateless app containers
# - Removes MailHog (use real SMTP in prod)
# - Fails fast on missing secrets: every sensitive env var is overridden with the
# ${VAR:?message} form, so `config`/`up` refuse to run unless a real value is set.
# Dev (base compose) keeps the ${VAR:-default} fallbacks and is unaffected.
# Required vars are listed in .env.example. Verify with:
# pwsh scripts/verify-prod-secrets-failfast.ps1
###############################################################
services:
# ============================================================
# INFRASTRUCTURE — secrets, messaging, cache, databases
# ============================================================
vault:
environment:
# Fail-fast: no committed dev token in production
VAULT_DEV_ROOT_TOKEN_ID: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset [] # remove 8200 exposure in prod
restart: unless-stopped
deploy:
resources:
limits:
memory: 512m
cpus: "0.5"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
kafka:
ports: !reset [] # remove 9092 exposure; services use kafka:29092 on infra-net
restart: unless-stopped
deploy:
resources:
limits:
memory: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
redis:
ports: !reset [] # remove 6379 exposure
restart: unless-stopped
deploy:
resources:
limits:
memory: 512m
cpus: "0.5"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
postgres-order:
restart: unless-stopped
deploy:
resources:
limits:
memory: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
postgres-product:
environment:
POSTGRES_USER: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
restart: unless-stopped
deploy:
resources:
limits:
memory: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
postgres-payment:
environment:
POSTGRES_USER: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
restart: unless-stopped
deploy:
resources:
limits:
memory: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
postgres-auth:
environment:
POSTGRES_USER: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
restart: unless-stopped
deploy:
resources:
limits:
memory: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
postgres-tenant:
environment:
POSTGRES_USER: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
restart: unless-stopped
deploy:
resources:
limits:
memory: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
mongodb:
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USERNAME:?MONGO_USERNAME must be set in production}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:?MONGO_PASSWORD must be set in production}
restart: unless-stopped
deploy:
resources:
limits:
memory: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
# ============================================================
# OBSERVABILITY
# ============================================================
zipkin:
ports: !reset [] # remove 9411 — access through monitoring-net only
restart: unless-stopped
deploy:
resources:
limits:
memory: 512m
cpus: "0.5"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
prometheus:
ports: !reset [] # internal only in prod
restart: unless-stopped
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
alertmanager:
ports: !reset []
restart: unless-stopped
deploy:
resources:
limits:
memory: 256m
cpus: "0.25"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
loki:
ports: !reset []
restart: unless-stopped
deploy:
resources:
limits:
memory: 512m
cpus: "0.5"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
promtail:
restart: unless-stopped
deploy:
resources:
limits:
memory: 256m
cpus: "0.25"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
grafana:
environment:
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:?GRAFANA_PASSWORD must be set in production}
# Keep :3000 for dashboards — accessible only through VPN/firewall rule in prod
restart: unless-stopped
deploy:
resources:
limits:
memory: 512m
cpus: "0.5"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
# MailHog removed in production — use real SMTP (set MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD)
mailhog:
deploy:
replicas: 0
# ============================================================
# SPRING CLOUD INFRASTRUCTURE
# ============================================================
config-service:
environment:
CONFIG_SERVER_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset [] # internal only — services access via service name
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
discovery-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
healthcheck:
# Override base healthcheck: base hardcodes eureka-secret-2024 in the URL, which
# breaks in prod with a real EUREKA_PASSWORD. Interpolate the real creds instead.
test: [ "CMD-SHELL", "wget -qO- 'http://${EUREKA_USERNAME:-eureka}:${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}@localhost:8761/actuator/health' | grep -q '\"status\":\"UP\"' || exit 1" ]
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
# ============================================================
# APPLICATION SERVICES — stateless, read_only + tmpfs
# ============================================================
gateway-api-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
REDIS_PASSWORD: ${REDIS_PASSWORD:?REDIS_PASSWORD must be set in production}
SPRING_DATA_REDIS_PASSWORD: ${REDIS_PASSWORD:?REDIS_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
# Keep :8222 — external entry point
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
authentication-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
POSTGRES_USERNAME: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
APP_ADMIN_PASSWORD: ${APP_ADMIN_PASSWORD:?APP_ADMIN_PASSWORD must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
tenant-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
POSTGRES_USERNAME: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
customer-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
MONGO_USERNAME: ${MONGO_USERNAME:?MONGO_USERNAME must be set in production}
MONGO_PASSWORD: ${MONGO_PASSWORD:?MONGO_PASSWORD must be set in production}
REDIS_PASSWORD: ${REDIS_PASSWORD:?REDIS_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
product-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
POSTGRES_USERNAME: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
REDIS_PASSWORD: ${REDIS_PASSWORD:?REDIS_PASSWORD must be set in production}
KAFKA_PASSWORD: ${KAFKA_PASSWORD:?KAFKA_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
INTERNAL_SERVICE_TOKEN: ${INTERNAL_SERVICE_TOKEN:?INTERNAL_SERVICE_TOKEN must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
order-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
POSTGRES_USERNAME: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
KAFKA_PASSWORD: ${KAFKA_PASSWORD:?KAFKA_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
INTERNAL_SERVICE_TOKEN: ${INTERNAL_SERVICE_TOKEN:?INTERNAL_SERVICE_TOKEN must be set in production}
# Optional, and intentionally NOT using `:?` — set only during a secret rotation, to keep the
# outgoing value accepted while callers roll onto the new one. Clear it once they have.
INTERNAL_SERVICE_TOKEN_PREVIOUS: ${INTERNAL_SERVICE_TOKEN_PREVIOUS:-}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
payment-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
POSTGRES_USERNAME: ${POSTGRES_USERNAME:?POSTGRES_USERNAME must be set in production}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in production}
KAFKA_PASSWORD: ${KAFKA_PASSWORD:?KAFKA_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
cart-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
REDIS_PASSWORD: ${REDIS_PASSWORD:?REDIS_PASSWORD must be set in production}
SPRING_DATA_REDIS_PASSWORD: ${REDIS_PASSWORD:?REDIS_PASSWORD must be set in production}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
notification-service:
environment:
SPRING_CLOUD_CONFIG_PASSWORD: ${CONFIG_SERVER_PASSWORD:?CONFIG_SERVER_PASSWORD must be set in production}
EUREKA_PASSWORD: ${EUREKA_PASSWORD:?EUREKA_PASSWORD must be set in production}
MONGO_USERNAME: ${MONGO_USERNAME:?MONGO_USERNAME must be set in production}
MONGO_PASSWORD: ${MONGO_PASSWORD:?MONGO_PASSWORD must be set in production}
KAFKA_PASSWORD: ${KAFKA_PASSWORD:?KAFKA_PASSWORD must be set in production}
MAIL_PASSWORD: ${MAIL_PASSWORD:?MAIL_PASSWORD must be set in production}
VAULT_TOKEN: ${VAULT_TOKEN:?VAULT_TOKEN must be set in production}
ports: !reset []
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
deploy:
resources:
limits:
memory: 1g
cpus: "1.0"
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"