-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
179 lines (169 loc) · 5.06 KB
/
docker-compose.yml
File metadata and controls
179 lines (169 loc) · 5.06 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
x-logging: &default-logging
# Cap container log files at 3 × 10 MB per service (30 MB max) so a noisy
# service can never fill the host disk. Older rotations are auto-deleted.
# This is the 2026-best-practice docker-compose pattern: YAML anchor +
# `<<: *default-logging` on every service.
driver: json-file
options:
max-size: "10m"
max-file: "3"
compress: "true"
services:
# ── Data layer (zeromail-internal only, not exposed to proxy) ────
postgres:
image: postgres:18.4
container_name: zeromail-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-zeromail}
POSTGRES_USER: ${POSTGRES_USER:-zeromail}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in .env}
# Mount custom init scripts (only run on fresh data volumes) + tuned config.
# 10-create-dev-db.sql is also runnable manually via `docker exec psql` for
# existing volumes — see scripts/ops/postgres/init/10-create-dev-db.sql.
command:
- "postgres"
- "-c"
- "shared_preload_libraries=pg_stat_statements"
- "-c"
- "pg_stat_statements.track=all"
- "-c"
- "pg_stat_statements.max=10000"
- "-c"
- "log_min_duration_statement=500"
- "-c"
- "log_lock_waits=on"
- "-c"
- "log_temp_files=0"
volumes:
- postgres_data:/var/lib/postgresql
- ./scripts/ops/postgres/init:/docker-entrypoint-initdb.d:ro
networks:
- zeromail-internal
healthcheck:
test: ["CMD-SHELL", "pg_isready -U zeromail -d zeromail"]
interval: 10s
timeout: 5s
retries: 5
logging: *default-logging
redis:
image: redis:8.6.3
container_name: zeromail-redis
restart: unless-stopped
volumes:
- redis_data:/data
networks:
- zeromail-internal
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
logging: *default-logging
# ── Operator infrastructure (proxy) ─────────────────────────────
nginx-proxy-manager:
image: jc21/nginx-proxy-manager:latest
container_name: zeromail-nginx-proxy-manager
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "127.0.0.1:81:81"
volumes:
- /opt/zeromail/npm-data:/data
- /opt/zeromail/npm-letsencrypt:/etc/letsencrypt
networks:
- proxy-network
logging: *default-logging
# ── Worker (internal only, runs Liquibase migrations) ────────────
worker:
build:
context: .
dockerfile: backend/worker/Dockerfile
image: ${ZEROMAIL_WORKER_IMAGE:-zeromail-worker:latest}
container_name: zeromail-worker
restart: unless-stopped
env_file: .env
networks:
- zeromail-internal
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8081/actuator/health || exit 1"]
interval: 30s
timeout: 10s
start_period: 90s
retries: 3
logging: *default-logging
# ── Frontend (proxy-network, NPM trỏ bằng tên zeromail-frontend) ──
frontend:
build:
context: .
dockerfile: apps/web/Dockerfile
args:
NEXT_PUBLIC_API_BASE: https://zeromail.vn
image: ${ZEROMAIL_FRONTEND_IMAGE:-zeromail-frontend:latest}
container_name: zeromail-frontend
restart: unless-stopped
env_file: .env
networks:
- proxy-network
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/ || exit 1"]
interval: 30s
timeout: 10s
start_period: 60s
retries: 3
logging: *default-logging
# ── Admin SPA (proxy-network, NPM trỏ admin.zeromail.vn → zeromail-admin:5174) ──
admin:
build:
context: .
dockerfile: apps/admin/Dockerfile
args:
VITE_ADMIN_API_BASE: https://admin.zeromail.vn
image: ${ZEROMAIL_ADMIN_IMAGE:-zeromail-admin:latest}
container_name: zeromail-admin
restart: unless-stopped
networks:
- proxy-network
healthcheck:
test: ["CMD-SHELL", "curl -fsS http://localhost:5174/healthz || exit 1"]
interval: 30s
timeout: 5s
start_period: 15s
retries: 3
logging: *default-logging
# ── API (proxy-network + internal, NPM trỏ bằng tên zeromail-api) ─
api:
build:
context: .
dockerfile: backend/api/Dockerfile
image: ${ZEROMAIL_API_IMAGE:-zeromail-api:latest}
container_name: zeromail-api
restart: unless-stopped
env_file: .env
networks:
- proxy-network
- zeromail-internal
depends_on:
worker:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/actuator/health || exit 1"]
interval: 30s
timeout: 10s
start_period: 90s
retries: 3
logging: *default-logging
networks:
proxy-network:
external: true
zeromail-internal:
external: true
volumes:
postgres_data:
redis_data: