-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
372 lines (364 loc) · 9.4 KB
/
Copy pathdocker-compose.yml
File metadata and controls
372 lines (364 loc) · 9.4 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
name: pec-erp
services:
postgres:
image: postgres:16-alpine
container_name: pec_postgres
restart: always
environment:
POSTGRES_DB: ${POSTGRES_DB:-pec}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
ports:
- 5432:5432
command: ["postgres", "-c", "statement_timeout=5000", "-c", "autovacuum_vacuum_scale_factor=0.05", "-c", "autovacuum_analyze_scale_factor=0.02", "-c", "wal_level=logical"]
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1024M
healthcheck:
test:
- CMD-SHELL
- pg_isready -U postgres -d pec
interval: 10s
timeout: 5s
retries: 5
pgbouncer:
image: edoburu/pgbouncer:latest
container_name: pec_pgbouncer
environment:
AUTH_TYPE: scram-sha-256
DB_USER: ${POSTGRES_USER:-postgres}
DB_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
DB_HOST: postgres
DB_NAME: ${POSTGRES_DB:-pec}
POOL_MODE: transaction
MAX_CLIENT_CONN: "1000"
DEFAULT_POOL_SIZE: "20"
IGNORE_STARTUP_PARAMETERS: extra_float_digits
ports:
- 6432:5432
depends_on:
- postgres
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1024M
db_migrator:
build:
context: .
dockerfile: apps/server/Dockerfile
container_name: pec_db_migrator
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@pgbouncer:5432/${POSTGRES_DB:-pec}?pgbouncer=true
DIRECT_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-pec}
depends_on:
postgres:
condition: service_healthy
pgbouncer:
condition: service_started
command: ["npx", "prisma", "migrate", "deploy", "--schema=node_modules/@pec/database/prisma/schema.prisma"]
networks:
- pec-network
backend:
build:
context: .
dockerfile: apps/server/Dockerfile
container_name: pec_backend
restart: always
ports:
# Port 4000 intentionally not exposed to host — Nginx is the entry point.
# Uncomment below only for direct debug access:
# - 4000:4000
- 50051:50051 # keep exposed if any internal tooling needs direct gRPC
environment:
JWT_SECRET: ${JWT_SECRET:-pec_secret_key_2026}
PORT: "4000"
NODE_ENV: production
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@pgbouncer:5432/${POSTGRES_DB:-pec}?pgbouncer=true
REPLICA_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@pgbouncer:5432/${POSTGRES_DB:-pec}?pgbouncer=true
DIRECT_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-pec}
REDIS_URL: redis://redis:6379
depends_on:
postgres:
condition: service_healthy
qdrant:
condition: service_started
healthcheck:
test:
- CMD
- wget
- -qO-
- http://localhost:4000/api
interval: 10s
timeout: 5s
retries: 5
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1024M
# Envoy removed — frontend uses REST + Socket.IO only (no gRPC-Web).
frontend:
build:
context: .
dockerfile: apps/frontend/Dockerfile
container_name: pec_frontend
restart: always
ports:
# Port 3001 not exposed to host — Nginx handles all traffic.
- "3001:3001"
environment:
NEXT_PUBLIC_API_URL: /api
INTERNAL_API_URL: ${INTERNAL_API_URL:-http://backend:4000/api}
NODE_ENV: production
PORT: "3001"
depends_on:
backend:
condition: service_healthy
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1024M
healthcheck:
test:
- CMD
- node
- -e
- "require('http').get('http://localhost:3001/', (r) => process.exit(r.statusCode < 500 ? 0 : 1)).on('error', () => process.exit(1))"
interval: 15s
timeout: 10s
retries: 5
start_period: 60s
nginx:
image: nginx:1.27-alpine
container_name: pec_nginx
restart: always
ports:
- "80:80"
# - "443:443" # uncomment when SSL cert is configured
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d/pec.prod.conf:/etc/nginx/conf.d/default.conf:ro
# - ./nginx/ssl:/etc/nginx/ssl:ro # uncomment when cert is available
depends_on:
backend:
condition: service_healthy
frontend:
condition: service_healthy
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M
healthcheck:
test: ["CMD", "nginx", "-t"]
interval: 30s
timeout: 5s
retries: 3
redis:
image: redis:7-alpine
container_name: pec_redis
restart: always
ports:
- 6379:6379
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1024M
healthcheck:
test:
- CMD
- redis-cli
- ping
interval: 10s
timeout: 5s
retries: 5
rabbitmq:
image: rabbitmq:3-management
container_name: pec_rabbitmq
restart: always
ports:
- 5672:5672
- 15672:15672
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1024M
healthcheck:
test:
- CMD
- rabbitmq-diagnostics
- check_port_connectivity
interval: 10s
timeout: 5s
retries: 5
qdrant:
image: qdrant/qdrant
container_name: pec_qdrant
restart: always
ports:
- "6333:6333"
- "6334:6334"
volumes:
- qdrant_data:/qdrant/storage
networks:
- pec-network
# frontend:
# build:
# context: .
# dockerfile: apps/frontend/Dockerfile
# container_name: pec_frontend
# restart: always
# ports:
# - 3000:3001
# environment:
# NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3000/api}
# INTERNAL_API_URL: ${INTERNAL_API_URL:-http://backend:4000/api}
# NODE_ENV: production
# depends_on:
# - backend
# networks:
# - pec-network
# logging:
# driver: json-file
# options:
# max-size: 10m
# max-file: "3"
# deploy:
# resources:
# limits:
# cpus: "1.0"
# memory: 1024M
dev_worker:
build:
context: .
dockerfile: apps/server/Dockerfile
container_name: pec_dev_worker
working_dir: /app
environment:
REDIS_URL: redis://redis:6379
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@pgbouncer:5432/${POSTGRES_DB:-pec}?pgbouncer=true
REPLICA_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@pgbouncer:5432/${POSTGRES_DB:-pec}?pgbouncer=true
DIRECT_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-pec}
NODE_ENV: production
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
command: ["node", "dist/src/background-jobs/worker.js"]
networks:
- pec-network
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1024M
prometheus:
image: prom/prometheus:latest
container_name: pec_prometheus
restart: always
ports:
- "9090:9090"
volumes:
- ./infra/prometheus.yml:/etc/prometheus/prometheus.yml:ro
networks:
- pec-network
grafana:
image: grafana/grafana:latest
container_name: pec_grafana
restart: always
ports:
- "3000:3000"
networks:
- pec-network
depends_on:
- prometheus
- loki
loki:
image: grafana/loki:latest
container_name: pec_loki
restart: always
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml
networks:
- pec-network
promtail:
image: grafana/promtail:latest
container_name: pec_promtail
restart: always
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./infra/promtail-config.yml:/etc/promtail/promtail-config.yml:ro
command: -config.file=/etc/promtail/promtail-config.yml
networks:
- pec-network
volumes:
postgres_data:
qdrant_data:
networks:
pec-network:
driver: bridge