-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
169 lines (159 loc) · 4.25 KB
/
docker-compose.yml
File metadata and controls
169 lines (159 loc) · 4.25 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
version: "3.8"
services:
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: fastapi_db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fastapi
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
# pgAdmin to view database online
pgadmin:
image: dpage/pgadmin4
container_name: fastapi_pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5050:80"
depends_on:
- postgres
restart: unless-stopped
# Redis Broker (Celery needs this)
redis:
image: redis:7-alpine
container_name: fastapi_redis
ports:
- "6379:6379"
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# FastAPI Application
fastapi:
build:
context: ./backend
dockerfile: Dockerfile
container_name: fastapi_app
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
ports:
- "8000:8000"
volumes:
- ./backend:/app
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/fastapi
- REDIS_BROKER_URL=redis://redis:6379/0
- REDIS_RESULT_BACKEND=redis://redis:6379/1
env_file:
- ./backend/.env
restart: unless-stopped
# Celery Email Worker (IO-bound, gevent, high concurrency)
celery_email_worker:
build:
context: ./backend
dockerfile: Dockerfile
container_name: fastapi_celery_email_worker
command: celery -A celery_worker worker -Q email_queue --pool=gevent --concurrency=50 --loglevel=info
volumes:
- ./backend:/app
depends_on:
redis:
condition: service_healthy
environment:
- REDIS_BROKER_URL=redis://redis:6379/0
- REDIS_RESULT_BACKEND=redis://redis:6379/1
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/fastapi
env_file:
- ./backend/.env
restart: unless-stopped
# Celery Cleanup Worker (maintenance_queue - prefork, low concurrency)
celery_cleanup_worker:
build:
context: ./backend
dockerfile: Dockerfile
container_name: fastapi_celery_cleanup_worker
command: celery -A celery_worker worker -Q maintenance_queue --concurrency=1 --loglevel=info
volumes:
- ./backend:/app
depends_on:
redis:
condition: service_healthy
environment:
- REDIS_BROKER_URL=redis://redis:6379/0
- REDIS_RESULT_BACKEND=redis://redis:6379/1
env_file:
- ./backend/.env
restart: unless-stopped
# Celery Beat (Scheduler for periodic tasks)
celery_beat:
build:
context: ./backend
dockerfile: Dockerfile
container_name: fastapi_celery_beat
command: celery -A celery_worker beat --loglevel=info
volumes:
- ./backend:/app
depends_on:
redis:
condition: service_healthy
environment:
- REDIS_BROKER_URL=redis://redis:6379/0
- REDIS_RESULT_BACKEND=redis://redis:6379/1
env_file:
- ./backend/.env
restart: unless-stopped
# Flower Dashboard (Celery monitoring)
flower:
build:
context: ./backend
dockerfile: Dockerfile
container_name: fastapi_flower
command: celery -A celery_worker flower --port=5555 --basic_auth=admin:admin
ports:
- "5555:5555"
volumes:
- ./backend:/app
depends_on:
- redis
- celery_email_worker
- celery_cleanup_worker
environment:
- REDIS_BROKER_URL=redis://redis:6379/0
- REDIS_RESULT_BACKEND=redis://redis:6379/1
restart: unless-stopped
# Frontend React App
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: fastapi_frontend
ports:
- "3000:3000"
volumes:
- ./frontend:/app
- /app/node_modules
depends_on:
- fastapi
environment:
- VITE_API_URL=http://localhost:8000
restart: unless-stopped
volumes:
postgres_data: