-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
518 lines (440 loc) · 14.4 KB
/
docker-compose.yml
File metadata and controls
518 lines (440 loc) · 14.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
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
# ============================================================================
# USDT Trading Platform Docker Compose Configuration
# ============================================================================
# Production-ready configuration with monitoring, logging, and health checks
# Version: 3.8 (Compatible with Docker Engine 19.03.0+)
# ============================================================================
# ============================================================================
# SERVICES CONFIGURATION
# ============================================================================
services:
# ============================================================================
# MySQL Database Service
# ============================================================================
mysql:
image: mysql:8.0.35
container_name: usdt-mysql
restart: ${DOCKER_RESTART_POLICY:-unless-stopped}
# Environment variables
environment:
MYSQL_ROOT_PASSWORD: UsdtTrading123!
MYSQL_DATABASE: ${MYSQL_DATABASE:-usdt_trading_platform}
MYSQL_USER: ${MYSQL_USER:-usdt_user}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-UsdtUser123!}
TZ: ${TZ:-UTC}
# Port mapping
ports:
- "${MYSQL_PORT:-3306}:3306"
# Volume mounts
volumes:
- mysql_data:/var/lib/mysql
- mysql_logs:/var/log/mysql
- ./devdocrecord/DBAAgent/database-schema.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf:ro
# Network configuration
networks:
- usdt-network
# Resource limits
deploy:
resources:
limits:
memory: ${MYSQL_MEMORY_LIMIT:-1g}
cpus: '${MYSQL_CPU_LIMIT:-1.0}'
reservations:
memory: 256m
cpus: '0.25'
# Health check
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p$$MYSQL_ROOT_PASSWORD", "--silent"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
# MySQL configuration
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --innodb-buffer-pool-size=512M
- --max-connections=200
# Logging configuration
logging:
driver: json-file
options:
max-size: "${LOG_MAX_SIZE:-50m}"
max-file: "${LOG_MAX_FILES:-3}"
labels: "service=mysql,environment=${SPRING_PROFILES_ACTIVE:-prod}"
# ============================================================================
# Redis Cache Service
# ============================================================================
redis:
image: redis:7.2-alpine
container_name: usdt-redis
restart: ${DOCKER_RESTART_POLICY:-unless-stopped}
# Environment variables
environment:
TZ: ${TZ:-UTC}
# Port mapping
ports:
- "${REDIS_PORT:-6379}:6379"
# Volume mounts
volumes:
- redis_data:/data
- redis_logs:/var/log/redis
- ./docker/redis/redis.conf:/etc/redis/redis.conf:ro
# Network configuration
networks:
- usdt-network
# Resource limits
deploy:
resources:
limits:
memory: ${REDIS_MEMORY_LIMIT:-512m}
cpus: '${REDIS_CPU_LIMIT:-0.5}'
reservations:
memory: 64m
cpus: '0.1'
# Health check
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# Redis configuration
command: redis-server /etc/redis/redis.conf --logfile /var/log/redis/redis.log
# Logging configuration
logging:
driver: json-file
options:
max-size: "${LOG_MAX_SIZE:-50m}"
max-file: "${LOG_MAX_FILES:-3}"
labels: "service=redis,environment=${SPRING_PROFILES_ACTIVE:-prod}"
# ============================================================================
# Backend API Service
# ============================================================================
backend:
build:
context: ./backend
dockerfile: Dockerfile
args:
- MAVEN_OPTS=-Dmaven.repo.local=/app/.m2/repository
container_name: usdt-backend
restart: ${DOCKER_RESTART_POLICY:-unless-stopped}
# Environment variables
environment:
# Spring configuration
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-prod}
# Database configuration
DB_HOST: mysql
DB_PORT: 3306
DB_NAME: ${MYSQL_DATABASE:-usdt_trading_platform}
DB_USERNAME: root
DB_PASSWORD: UsdtTrading123!
DB_CONNECTION_TIMEOUT: ${DB_CONNECTION_TIMEOUT:-30}
# Redis configuration
REDIS_HOST: redis
REDIS_PORT: ${REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
REDIS_TIMEOUT: ${REDIS_TIMEOUT:-5000}
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+F6G2D4vE7K1L+G3VQs5L8G9F8D1vE3C6L+G4VQs2L+F7G1D9vE5K8L+G6VQs7QIDAQAB}
BUSINESS_SECURITY_RSA_PRIVATE_KEY: ${BUSINESS_SECURITY_RSA_PRIVATE_KEY:-}
# Email configuration
MAIL_HOST: ${MAIL_HOST:-g-mate.org}
MAIL_PORT: ${MAIL_PORT:-587}
MAIL_USERNAME: ${MAIL_USERNAME:-JasonWang}
MAIL_PASSWORD: ${MAIL_PASSWORD:-Jason~76114}
# File storage configuration
FILE_STORAGE_PATH: ${FILE_STORAGE_PATH:-/app/uploads}
FILE_MAX_SIZE: ${FILE_MAX_SIZE:-100MB}
# Other configurations
TZ: ${TZ:-UTC}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
# Port mapping
ports:
- "${BACKEND_PORT:-8090}:8080"
# Volume mounts
volumes:
- backend_logs:/app/logs
- backend_uploads:/app/uploads
- backend_temp:/app/temp
- maven_cache:/app/.m2/repository
# Network configuration
networks:
- usdt-network
# Service dependencies
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
# Resource limits
deploy:
resources:
limits:
memory: ${BACKEND_MEMORY_LIMIT:-2g}
cpus: '${BACKEND_CPU_LIMIT:-1.0}'
reservations:
memory: 512m
cpus: '0.5'
# Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:8080/actuator/health", "--connect-timeout", "5", "--max-time", "10"]
interval: 30s
timeout: 15s
retries: 5
start_period: 60s
# Logging configuration
logging:
driver: json-file
options:
max-size: "${LOG_MAX_SIZE:-100m}"
max-file: "${LOG_MAX_FILES:-5}"
labels: "service=backend,environment=${SPRING_PROFILES_ACTIVE:-prod}"
# ============================================================================
# Admin Frontend Service
# ============================================================================
admin-frontend:
build:
context: ./frontend/admin
dockerfile: Dockerfile
args:
- NODE_ENV=production
- BUILD_ENV=${SPRING_PROFILES_ACTIVE:-prod}
container_name: usdt-admin-frontend
restart: ${DOCKER_RESTART_POLICY:-unless-stopped}
# Environment variables
environment:
TZ: ${TZ:-UTC}
# Port mapping
ports:
- "${FRONTEND_ADMIN_PORT:-3000}:80"
# Volume mounts
volumes:
- admin_logs:/var/log/nginx
# Network configuration
networks:
- usdt-network
# Service dependencies
depends_on:
backend:
condition: service_healthy
# Resource limits
deploy:
resources:
limits:
memory: ${FRONTEND_MEMORY_LIMIT:-256m}
cpus: '${FRONTEND_CPU_LIMIT:-0.5}'
reservations:
memory: 32m
cpus: '0.1'
# Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# Logging configuration
logging:
driver: json-file
options:
max-size: "${LOG_MAX_SIZE:-50m}"
max-file: "${LOG_MAX_FILES:-3}"
labels: "service=admin-frontend,environment=${SPRING_PROFILES_ACTIVE:-prod}"
# ============================================================================
# User Frontend Service
# ============================================================================
user-frontend:
build:
context: ./frontend/user
dockerfile: Dockerfile
args:
- NODE_ENV=production
- BUILD_ENV=${SPRING_PROFILES_ACTIVE:-prod}
container_name: usdt-user-frontend
restart: ${DOCKER_RESTART_POLICY:-unless-stopped}
# Environment variables
environment:
TZ: ${TZ:-UTC}
# Port mapping
ports:
- "${FRONTEND_USER_PORT:-3001}:80"
# Volume mounts
volumes:
- user_logs:/var/log/nginx
# Network configuration
networks:
- usdt-network
# Service dependencies
depends_on:
backend:
condition: service_healthy
# Resource limits
deploy:
resources:
limits:
memory: ${FRONTEND_MEMORY_LIMIT:-256m}
cpus: '${FRONTEND_CPU_LIMIT:-0.5}'
reservations:
memory: 32m
cpus: '0.1'
# Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# Logging configuration
logging:
driver: json-file
options:
max-size: "${LOG_MAX_SIZE:-50m}"
max-file: "${LOG_MAX_FILES:-3}"
labels: "service=user-frontend,environment=${SPRING_PROFILES_ACTIVE:-prod}"
# ============================================================================
# Nginx Reverse Proxy Service
# ============================================================================
nginx:
image: nginx:1.25-alpine
container_name: usdt-nginx
restart: ${DOCKER_RESTART_POLICY:-unless-stopped}
# Environment variables
environment:
TZ: ${TZ:-UTC}
# Port mapping
ports:
- "${NGINX_HTTP_PORT:-80}:80"
- "${NGINX_HTTPS_PORT:-443}:443"
# Volume mounts
volumes:
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
- ./docker/nginx/ssl:/etc/nginx/ssl:ro
- nginx_logs:/var/log/nginx
- nginx_cache:/var/cache/nginx
- backend_uploads:/app/uploads:ro
# Network configuration
networks:
- usdt-network
# Service dependencies
depends_on:
backend:
condition: service_healthy
admin-frontend:
condition: service_healthy
user-frontend:
condition: service_healthy
# Resource limits
deploy:
resources:
limits:
memory: ${NGINX_MEMORY_LIMIT:-256m}
cpus: '${NGINX_CPU_LIMIT:-0.5}'
reservations:
memory: 32m
cpus: '0.1'
# Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# Logging configuration
logging:
driver: json-file
options:
max-size: "${LOG_MAX_SIZE:-100m}"
max-file: "${LOG_MAX_FILES:-5}"
labels: "service=nginx,environment=${SPRING_PROFILES_ACTIVE:-prod}"
# ============================================================================
# VOLUME CONFIGURATION
# ============================================================================
# Persistent data storage volumes
volumes:
# Database volumes
mysql_data:
driver: local
driver_opts:
type: none
o: bind
device: ${MYSQL_DATA_PATH:-./data/mysql}
mysql_logs:
driver: local
driver_opts:
type: none
o: bind
device: ${MYSQL_LOGS_PATH:-./logs/mysql}
redis_data:
driver: local
driver_opts:
type: none
o: bind
device: ${REDIS_DATA_PATH:-./data/redis}
redis_logs:
driver: local
driver_opts:
type: none
o: bind
device: ${REDIS_LOGS_PATH:-./logs/redis}
# Application volumes
backend_logs:
driver: local
driver_opts:
type: none
o: bind
device: ${BACKEND_LOGS_PATH:-./logs/backend}
backend_uploads:
driver: local
driver_opts:
type: none
o: bind
device: ${BACKEND_UPLOADS_PATH:-./data/uploads}
backend_temp:
driver: local
driver_opts:
type: none
o: bind
device: ${BACKEND_TEMP_PATH:-./data/temp}
# Frontend volumes
admin_logs:
driver: local
driver_opts:
type: none
o: bind
device: ${ADMIN_LOGS_PATH:-./logs/admin}
user_logs:
driver: local
driver_opts:
type: none
o: bind
device: ${USER_LOGS_PATH:-./logs/user}
# Nginx volumes
nginx_logs:
driver: local
driver_opts:
type: none
o: bind
device: ${NGINX_LOGS_PATH:-./logs/nginx}
nginx_cache:
driver: local
driver_opts:
type: none
o: bind
device: ${NGINX_CACHE_PATH:-./data/nginx-cache}
# Build cache
maven_cache:
driver: local
name: ${PROJECT_NAME:-usdt-trading-platform}_maven_cache
# ============================================================================
# NETWORK CONFIGURATION
# ============================================================================
# Custom bridge network for service communication
networks:
usdt-network:
driver: bridge