-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
359 lines (341 loc) · 9.99 KB
/
docker-compose.prod.yml
File metadata and controls
359 lines (341 loc) · 9.99 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
version: '3.8'
# Production Docker Compose Configuration for NGSmodule
# Usage: docker-compose -f docker-compose.prod.yml up -d
services:
# ===========================================
# Database Services
# ===========================================
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: ngsmodule-postgres-prod
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-ngsmodule}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
POSTGRES_DB: ${POSTGRES_DB:-ngsmodule}
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./backups/postgres:/backups
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-ngsmodule}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Redis Cache
redis:
image: redis:7-alpine
container_name: ngsmodule-redis-prod
restart: unless-stopped
command: >
redis-server
--requirepass ${REDIS_PASSWORD:?REDIS_PASSWORD is required}
--maxmemory 512mb
--maxmemory-policy allkeys-lru
--save 900 1
--save 300 10
--save 60 10000
--appendonly yes
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 3s
retries: 5
start_period: 10s
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# MinIO Object Storage
minio:
image: minio/minio:latest
container_name: ngsmodule-minio-prod
restart: unless-stopped
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:?MINIO_ROOT_USER is required}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:?MINIO_ROOT_PASSWORD is required}
MINIO_BROWSER: ${MINIO_BROWSER:-on}
ports:
- "${MINIO_API_PORT:-9000}:9000"
- "${MINIO_CONSOLE_PORT:-9001}:9001"
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
start_period: 10s
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ===========================================
# Application Services
# ===========================================
# Backend API
backend:
build:
context: ./backend
dockerfile: Dockerfile
args:
- BUILD_DATE=${BUILD_DATE:-2024-01-01}
- VCS_REF=${VCS_REF:-latest}
image: ngsmodule/backend:${IMAGE_TAG:-latest}
container_name: ngsmodule-backend-prod
restart: unless-stopped
environment:
- ENVIRONMENT=production
- DEBUG=false
- DATABASE_URL=postgresql://${POSTGRES_USER:-ngsmodule}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-ngsmodule}
- REDIS_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:6379/1
- MINIO_URL=minio:9000
- MINIO_ACCESS_KEY=${MINIO_ROOT_USER}
- MINIO_SECRET_KEY=${MINIO_ROOT_PASSWORD}
- SECRET_KEY=${SECRET_KEY:?SECRET_KEY is required}
- JWT_SECRET_KEY=${JWT_SECRET_KEY:?JWT_SECRET_KEY is required}
- JWT_ALGORITHM=${JWT_ALGORITHM:-HS256}
- ACCESS_TOKEN_EXPIRE_MINUTES=${ACCESS_TOKEN_EXPIRE_MINUTES:-30}
- REFRESH_TOKEN_EXPIRE_DAYS=${REFRESH_TOKEN_EXPIRE_DAYS:-7}
- NGS_PIPELINE_DIR=/app/NGSmodule
- STORAGE_PATH=/data/storage
- UPLOAD_PATH=/data/uploads
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- SENTRY_DSN=${SENTRY_DSN:-}
ports:
- "8000:8000"
volumes:
- ./:/app/NGSmodule:ro
- upload_data:/data/uploads
- work_data:/data/ngsmodule_work
- result_data:/data/ngsmodule_results
- storage_data:/data/storage
- logs:/app/logs
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
# Celery Worker
celery-worker:
build:
context: ./backend
dockerfile: Dockerfile
image: ngsmodule/backend:${IMAGE_TAG:-latest}
container_name: ngsmodule-celery-worker-prod
restart: unless-stopped
command: celery -A app.workers.celery_app worker --loglevel=info --concurrency=${CELERY_CONCURRENCY:-4} --max-tasks-per-child=100
environment:
- ENVIRONMENT=production
- DATABASE_URL=postgresql://${POSTGRES_USER:-ngsmodule}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-ngsmodule}
- REDIS_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:6379/1
- NGS_PIPELINE_DIR=/app/NGSmodule
- LOG_LEVEL=${LOG_LEVEL:-INFO}
volumes:
- ./:/app/NGSmodule:ro
- work_data:/data/ngsmodule_work
- result_data:/data/ngsmodule_results
- storage_data:/data/storage
- logs:/app/logs
depends_on:
- postgres
- redis
- backend
healthcheck:
test: ["CMD-SHELL", "celery -A app.workers.celery_app inspect ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
# Celery Beat Scheduler
celery-beat:
build:
context: ./backend
dockerfile: Dockerfile
image: ngsmodule/backend:${IMAGE_TAG:-latest}
container_name: ngsmodule-celery-beat-prod
restart: unless-stopped
command: celery -A app.workers.celery_app beat --loglevel=info
environment:
- ENVIRONMENT=production
- DATABASE_URL=postgresql://${POSTGRES_USER:-ngsmodule}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-ngsmodule}
- REDIS_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:6379/1
- LOG_LEVEL=${LOG_LEVEL:-INFO}
volumes:
- logs:/app/logs
depends_on:
- postgres
- redis
- backend
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Flower (Celery monitoring) - Optional
flower:
build:
context: ./backend
dockerfile: Dockerfile
image: ngsmodule/backend:${IMAGE_TAG:-latest}
container_name: ngsmodule-flower-prod
restart: unless-stopped
command: celery -A app.workers.celery_app flower --port=5555 --basic_auth=${FLOWER_USER:-admin}:${FLOWER_PASSWORD:?FLOWER_PASSWORD is required}
environment:
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:6379/1
ports:
- "5555:5555"
depends_on:
- redis
- celery-worker
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
profiles:
- monitoring
# ===========================================
# Frontend Service
# ===========================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
- VITE_API_URL=${VITE_API_URL:-https://api.yourdomain.com/api/v1}
- VITE_WS_URL=${VITE_WS_URL:-wss://api.yourdomain.com/ws}
image: ngsmodule/frontend:${IMAGE_TAG:-latest}
container_name: ngsmodule-frontend-prod
restart: unless-stopped
expose:
- "80"
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ===========================================
# Reverse Proxy (Nginx)
# ===========================================
nginx:
image: nginx:alpine
container_name: ngsmodule-nginx-prod
restart: unless-stopped
ports:
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
- "8080:8080" # Monitoring
volumes:
- ./nginx-proxy.conf:/etc/nginx/conf.d/default.conf:ro
- ./ssl:/etc/nginx/ssl:ro # SSL certificates (create this directory)
- nginx_logs:/var/log/nginx
depends_on:
- frontend
- backend
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/nginx-status"]
interval: 30s
timeout: 10s
retries: 3
networks:
- ngsmodule_network
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
# ===========================================
# Volumes
# ===========================================
volumes:
postgres_data:
driver: local
redis_data:
driver: local
minio_data:
driver: local
upload_data:
driver: local
work_data:
driver: local
result_data:
driver: local
storage_data:
driver: local
logs:
driver: local
nginx_logs:
driver: local
# ===========================================
# Networks
# ===========================================
networks:
ngsmodule_network:
driver: bridge
ipam:
config:
- subnet: 172.28.0.0/16