-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
431 lines (411 loc) · 10.6 KB
/
Copy pathdocker-compose.yml
File metadata and controls
431 lines (411 loc) · 10.6 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
services:
# Service 1: hpc_dispatch_management (FastAPI)
dispatch_service:
build:
context: ./hpc_dispatch_management
dockerfile: Dockerfile
container_name: hpc_dispatch_service
command: uvicorn src.hpc_dispatch_management.main:app --host 0.0.0.0 --port 8888 --reload
restart: unless-stopped
ports:
- "8888:8888"
volumes:
- ./hpc_dispatch_management/src:/app/src
deploy:
resources:
limits:
memory: 300M
environment:
- APP_ENV=local
- NOTIFICATION_SERVICE_URL=http://sys_web/api/v1/events/publish
- HPC_USER_SERVICE_URL=http://sys_web/api/v1
- HPC_DRIVE_SERVICE_URL=http://hpc_drive:7777/api/v1/drive
- DATABASE_URL=mysql+pymysql://root:root@shared_db:3306/hpc_dispatch
- JWT_SECRET=${JWT_SECRET}
- JWT_ALGO=HS256
depends_on:
- shared_db
networks:
- hpc_shared_network
# Service 2: hpc_drive (FastAPI)
hpc_drive:
build:
context: ./hpc_drive
dockerfile: Dockerfile
container_name: hpc_drive_service
command: uvicorn src.hpc_drive.main:app --host 0.0.0.0 --port 7777 --reload
ports:
- "7777:7777"
volumes:
- ./hpc_drive/src:/app/src
- drive_data:/app/data
- uploads_data:/app/src/hpc_drive/uploads
deploy:
resources:
limits:
memory: 300M
environment:
DATABASE_URL: "mysql+pymysql://root:root@shared_db:3306/hpc_drive"
JWT_SECRET: ${JWT_SECRET}
depends_on:
shared_db:
condition: service_healthy
networks:
- hpc_shared_network
restart: unless-stopped
# Service 3: LMS (Spring Boot)
lms-app:
build:
context: ./LMS
dockerfile: Dockerfile
args:
SKIP_TESTS: "true"
container_name: lms-app
restart: unless-stopped
ports:
- "8083:8083"
deploy:
resources:
limits:
memory: 700M
environment:
SERVER_PORT: 8083
SPRING_PROFILES_ACTIVE: prod
TZ: Asia/Ho_Chi_Minh
SPRING_DATASOURCE_URL: jdbc:mysql://shared_db:3306/LMS?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Ho_Chi_Minh&characterEncoding=UTF-8
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
NOTIFICATION_SERVICE_URL: http://sys_web:80
IDENTITY_SERVICE_URL: http://sys_web:80
JWT_SECRET: ${JWT_SECRET}
# Explicitly allow local frontend origins to bypass prod overrides
CORS_ALLOWED_ORIGINS: "http://localhost:3001,http://127.0.0.1:3001"
VNPAY_TMN_CODE: ${VNPAY_TMN_CODE}
VNPAY_SECRET_KEY: ${VNPAY_SECRET_KEY}
VNPAY_PAY_URL: ${VNPAY_PAY_URL}
VNPAY_RETURN_URL: ${VNPAY_RETURN_URL}
REDIS_HOST: sys_redis
REDIS_PORT: 6379
volumes:
- ./LMS/uploads:/app/uploads
- ./LMS/logs:/app/logs
depends_on:
shared_db:
condition: service_healthy
networks:
- hpc_shared_network
# Service 4: Module-Tuyendung (Laravel)
tuyen_app:
build:
context: ./Module_Tuyendung/back-end
dockerfile: Dockerfile
container_name: module_tuyendung
working_dir: /var/www/html
deploy:
resources:
limits:
memory: 512M
environment:
- APP_URL=${APP_URL_TUYEN}
# UPDATED: Points to shared_db
- DB_HOST=shared_db
- JWT_SECRET=${JWT_SECRET}
- DB_PORT=3306
- DB_DATABASE=module_tuyendung
- DB_USERNAME=root
- DB_PASSWORD=root
volumes:
- ./Module_Tuyendung/back-end:/var/www/html
networks:
- hpc_shared_network
depends_on:
- shared_db
tuyen_web:
image: nginx:alpine
container_name: backend_tuyendung
ports:
- "8020:80"
deploy:
resources:
limits:
memory: 128M
volumes:
- ./Module_Tuyendung/back-end:/var/www/html
- ./Module_Tuyendung/back-end/nginx:/etc/nginx/conf.d:ro
networks:
- hpc_shared_network
depends_on:
- tuyen_app
# Service 5: System-Management (Laravel)
sys_app:
build:
context: ./System-Management
dockerfile: Dockerfile
container_name: hpc_app
restart: unless-stopped
working_dir: /var/www
volumes:
- ./System-Management:/var/www
environment:
- APP_URL=${APP_URL_SYS}
- DB_HOST=shared_db
- DB_PORT=3306
- DB_DATABASE=system_services
- DB_USERNAME=root
- DB_PASSWORD=root
- JWT_SECRET=${JWT_SECRET}
- KAFKA_BROKERS=sys_kafka:9092
- REDIS_HOST=sys_redis
- REDIS_PORT=6379
- REDIS_CLIENT=predis
- APP_TIMEZONE=Asia/Ho_Chi_Minh
- KAFKA_TOPIC=notifications
networks:
- hpc_shared_network
depends_on:
- shared_db
sys_web:
image: nginx:alpine
container_name: hpc_web
restart: unless-stopped
ports:
- "8082:80"
deploy:
resources:
limits:
memory: 128M
volumes:
- ./System-Management:/var/www
- ./System-Management/nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- sys_app
- sys_reverb
networks:
- hpc_shared_network
sys_redis:
image: redis:alpine
container_name: hpc_redis
restart: unless-stopped
deploy:
resources:
limits:
memory: 256M
ports:
- "6380:6379"
networks:
hpc_shared_network:
aliases:
- redis
sys_reverb:
build:
context: ./System-Management
dockerfile: Dockerfile
container_name: hpc_reverb
command: php artisan reverb:start
working_dir: /var/www
deploy:
resources:
limits:
memory: 256MB
volumes:
- ./System-Management:/var/www
depends_on:
- sys_app
- sys_redis
ports:
- "8081:8080"
networks:
hpc_shared_network:
aliases:
- reverb
sys_zookeeper:
image: confluentinc/cp-zookeeper:latest
container_name: hpc_zookeeper
restart: unless-stopped
deploy:
resources:
limits:
memory: 256M
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
KAFKA_OPTS: "-Xmx128m -Xms128m"
ports:
- "2181:2181"
networks:
hpc_shared_network:
aliases:
- zookeeper
sys_kafka:
image: confluentinc/cp-kafka:6.2.10
container_name: hpc_kafka
restart: unless-stopped
depends_on:
- sys_zookeeper
ports:
- "9092:9092"
deploy:
resources:
limits:
memory: 512M
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: sys_zookeeper:2181
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://hpc_kafka:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_NUM_PARTITIONS: 3
KAFKA_DEFAULT_REPLICATION_FACTOR: 1
networks:
hpc_shared_network:
aliases:
- kafka
sys_queue_worker:
build:
context: ./System-Management
dockerfile: Dockerfile
container_name: hpc_queue_worker
restart: unless-stopped
working_dir: /var/www
volumes:
- ./System-Management:/var/www
# ---> ADD THIS ENTIRE BLOCK <---
environment:
- DB_HOST=shared_db
- DB_PORT=3306
- DB_DATABASE=system_services
- DB_USERNAME=root
- DB_PASSWORD=root
- REDIS_HOST=sys_redis
- REDIS_PORT=6379
- REDIS_CLIENT=predis
- KAFKA_BROKERS=sys_kafka:9092
- APP_TIMEZONE=Asia/Ho_Chi_Minh
- KAFKA_TOPIC=notifications
command: php artisan queue:work --queue=default --verbose --tries=3 --timeout=90
depends_on:
- sys_app
- sys_redis
networks:
- hpc_shared_network
sys_kafka_consumer:
build:
context: ./System-Management
dockerfile: Dockerfile
container_name: hpc_kafka_consumer
restart: unless-stopped
working_dir: /var/www
volumes:
- ./System-Management:/var/www
# ---> ADD THIS ENTIRE BLOCK <---
environment:
- DB_HOST=shared_db
- DB_PORT=3306
- DB_DATABASE=system_services
- DB_USERNAME=root
- DB_PASSWORD=root
- REDIS_HOST=sys_redis
- REDIS_PORT=6379
- REDIS_CLIENT=predis
- KAFKA_BROKERS=sys_kafka:9092
- APP_TIMEZONE=Asia/Ho_Chi_Minh
- KAFKA_TOPIC=notifications
command: php artisan kafka:consume
depends_on:
- sys_app
- sys_kafka
networks:
- hpc_shared_network
# Service 6: fe-portal (Next.js)
fe_portal:
build:
context: ./fe-portal
dockerfile: Dockerfile
target: dev
container_name: fe_portal
restart: unless-stopped
ports:
- "3001:3001"
deploy:
resources:
limits:
memory: 1G
environment:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
- NEXT_PUBLIC_REVERB_HOST=${NEXT_PUBLIC_REVERB_HOST}
- STORAGE_SERVICE_URL=http://sys_web:80/api
- NEXT_PUBLIC_REVERB_PORT=8082
- NEXT_PUBLIC_REVERB_SCHEME=http
volumes:
- ./fe-portal:/app
- /app/node_modules
networks:
- hpc_shared_network
# Service 7: Shared Database
shared_db:
image: mysql:8.0
container_name: shared_mysql
restart: unless-stopped
command: --default-authentication-plugin=mysql_native_password
deploy:
resources:
limits:
memory: 1.5G
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- "3306:3306"
volumes:
- shared_db_data:/var/lib/mysql
- ./create_dbs.sql:/docker-entrypoint-initdb.d/init.sql:ro
networks:
- hpc_shared_network
healthcheck:
test:
["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
interval: 10s
timeout: 5s
retries: 10
# Service 8: Db Gate
dbgate:
image: dbgate/dbgate
container_name: hpc_dbgate
restart: always
ports:
- "8067:3000"
networks:
- hpc_shared_network
# Service 9: Loki
loki:
image: grafana/loki:latest
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml
networks:
- hpc_shared_network
# Service 10: promttail
promtail:
image: grafana/promtail:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro # CRITICAL
- /var/lib/docker/containers:/var/lib/docker/containers:ro # CRITICAL
- ./promtail-config.yml:/etc/promtail/config.yml:ro
command: -config.file=/etc/promtail/config.yml
networks:
- hpc_shared_network
# Service 11: grafana
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
networks:
- hpc_shared_network
networks:
hpc_shared_network:
driver: bridge
volumes:
drive_data:
uploads_data:
shared_db_data: