-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
340 lines (326 loc) · 10.3 KB
/
docker-compose.yml
File metadata and controls
340 lines (326 loc) · 10.3 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
services:
# ============================================
# Infrastructure Services
# ============================================
postgres:
image: postgres:16-alpine
container_name: openapi-postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-openapi}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-openapi_secret}
POSTGRES_DB: ${POSTGRES_DB:-openapi_showcase}
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-openapi} -d ${POSTGRES_DB:-openapi_showcase}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- openapi-network
redis:
image: redis:7-alpine
container_name: openapi-redis
command: redis-server --appendonly yes
volumes:
- redis_data:/data
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- openapi-network
# ============================================
# Database Migrations
# ============================================
migrations:
build:
context: .
target: production
container_name: openapi-migrations
command: python -m alembic upgrade head
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
depends_on:
postgres:
condition: service_healthy
networks:
- openapi-network
restart: "no"
# ============================================
# Database Seeding (runs once after migrations)
# ============================================
seeder:
build:
context: .
target: production
container_name: openapi-seeder
command: python scripts/seed_data.py
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
depends_on:
migrations:
condition: service_completed_successfully
networks:
- openapi-network
restart: "no"
# ============================================
# Background Task Processing
# ============================================
celery-worker:
build:
context: .
target: production
container_name: openapi-celery-worker
command: celery -A shared.celery_app worker --loglevel=info
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- CELERY_BROKER_URL=redis://redis:6379/1
- CELERY_RESULT_BACKEND=redis://redis:6379/2
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- openapi-network
celery-beat:
build:
context: .
target: production
container_name: openapi-celery-beat
command: celery -A shared.celery_app beat --loglevel=info
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- CELERY_BROKER_URL=redis://redis:6379/1
- CELERY_RESULT_BACKEND=redis://redis:6379/2
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- openapi-network
flower:
build:
context: .
target: production
container_name: openapi-flower
command: >
celery -A shared.celery_app flower
--port=5555
--url_prefix=flower
--persistent=true
--db=/data/flower.db
--max_tasks=10000
environment:
- CELERY_BROKER_URL=redis://redis:6379/1
- CELERY_RESULT_BACKEND=redis://redis:6379/2
- FLOWER_BASIC_AUTH=${FLOWER_USER:-admin}:${FLOWER_PASSWORD:-admin}
volumes:
- flower_data:/data
ports:
- "5555:5555"
depends_on:
- celery-worker
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5555/flower/healthcheck"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
networks:
- openapi-network
# ============================================
# API Services
# ============================================
auth-api:
build:
context: .
target: production
container_name: openapi-auth-api
command: uvicorn apps.auth.main:app --host 0.0.0.0 --port 8000
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-super-secret-key-change-in-production}
ports:
- "8001:8000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- openapi-network
orders-api:
build:
context: .
target: production
container_name: openapi-orders-api
command: uvicorn apps.orders.main:app --host 0.0.0.0 --port 8000
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-super-secret-key-change-in-production}
- CELERY_BROKER_URL=redis://redis:6379/1
ports:
- "8002:8000"
depends_on:
migrations:
condition: service_completed_successfully
redis:
condition: service_healthy
auth-api:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- openapi-network
file-processor-api:
build:
context: .
target: production
container_name: openapi-file-processor-api
command: uvicorn apps.file_processor.main:app --host 0.0.0.0 --port 8000
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-super-secret-key-change-in-production}
- CELERY_BROKER_URL=redis://redis:6379/1
ports:
- "8003:8000"
depends_on:
migrations:
condition: service_completed_successfully
redis:
condition: service_healthy
auth-api:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- openapi-network
notifications-api:
build:
context: .
target: production
container_name: openapi-notifications-api
command: uvicorn apps.notifications.main:app --host 0.0.0.0 --port 8000
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-super-secret-key-change-in-production}
ports:
- "8004:8000"
depends_on:
migrations:
condition: service_completed_successfully
redis:
condition: service_healthy
auth-api:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- openapi-network
webhook-tester-api:
build:
context: .
target: production
container_name: openapi-webhook-tester-api
command: uvicorn apps.webhook_tester.main:app --host 0.0.0.0 --port 8000
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-super-secret-key-change-in-production}
ports:
- "8005:8000"
depends_on:
migrations:
condition: service_completed_successfully
redis:
condition: service_healthy
auth-api:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- openapi-network
# ============================================
# API Gateway (Combined Documentation)
# ============================================
gateway:
build:
context: .
target: production
container_name: openapi-gateway
command: uvicorn apps.gateway.main:app --host 0.0.0.0 --port 8000
environment:
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-openapi}:${POSTGRES_PASSWORD:-openapi_secret}@postgres:5432/${POSTGRES_DB:-openapi_showcase}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-super-secret-key-change-in-production}
- AUTH_API_URL=http://auth-api:8000
- ORDERS_API_URL=http://orders-api:8000
- FILE_PROCESSOR_API_URL=http://file-processor-api:8000
- NOTIFICATIONS_API_URL=http://notifications-api:8000
- WEBHOOK_TESTER_API_URL=http://webhook-tester-api:8000
ports:
- "8000:8000"
depends_on:
auth-api:
condition: service_healthy
orders-api:
condition: service_healthy
file-processor-api:
condition: service_healthy
notifications-api:
condition: service_healthy
webhook-tester-api:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- openapi-network
volumes:
postgres_data:
redis_data:
flower_data:
networks:
openapi-network:
driver: bridge