-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
181 lines (173 loc) · 4.82 KB
/
docker-compose.yml
File metadata and controls
181 lines (173 loc) · 4.82 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
# Production Docker Compose configuration
version: '3.9'
services:
# PostgreSQL Database
db:
image: postgres:15-alpine
container_name: hardword_db
environment:
POSTGRES_DB: ${DB_NAME:-hardword}
POSTGRES_USER: ${DB_USER:-hardword}
POSTGRES_PASSWORD: ${DB_PASSWORD}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-hardword}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
networks:
- hardword_network
# Redis Cache & Message Broker
redis:
image: redis:7-alpine
container_name: hardword_redis
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
volumes:
- redis_data:/data
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
restart: unless-stopped
networks:
- hardword_network
# Django Backend
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: hardword_backend
command: gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 4 --timeout 120 --access-logfile - --error-logfile -
volumes:
- media_data:/app/media
- static_data:/app/staticfiles
- backend_logs:/app/logs
environment:
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
- 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/0
- DJANGO_SETTINGS_MODULE=config.settings.production
- SECRET_KEY=${SECRET_KEY}
- DEBUG=False
- ALLOWED_HOSTS=${ALLOWED_HOSTS:-localhost,127.0.0.1}
- GROQ_API_KEY=${GROQ_API_KEY}
- WHISPER_MODEL=${WHISPER_MODEL:-base}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/health/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
networks:
- hardword_network
# Celery Worker
celery:
build:
context: ./backend
dockerfile: Dockerfile
container_name: hardword_celery
command: celery -A config worker --loglevel=info --concurrency=4
volumes:
- media_data:/app/media
- celery_logs:/app/logs
environment:
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
- 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/0
- DJANGO_SETTINGS_MODULE=config.settings.production
- SECRET_KEY=${SECRET_KEY}
- DEBUG=False
- GROQ_API_KEY=${GROQ_API_KEY}
- WHISPER_MODEL=${WHISPER_MODEL:-base}
depends_on:
- backend
- redis
healthcheck:
test: ["CMD-SHELL", "celery -A config inspect ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
restart: unless-stopped
networks:
- hardword_network
# React Frontend
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: hardword_frontend
depends_on:
- backend
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
restart: unless-stopped
networks:
- hardword_network
# Nginx Reverse Proxy
nginx:
image: nginx:alpine
container_name: hardword_nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./docker/nginx-proxy.conf:/etc/nginx/conf.d/default.conf:ro
- static_data:/app/staticfiles:ro
- media_data:/app/media:ro
- nginx_logs:/var/log/nginx
depends_on:
- backend
- frontend
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health/"]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
restart: unless-stopped
networks:
- hardword_network
# Named volumes for data persistence
volumes:
postgres_data:
name: hardword_postgres_data
redis_data:
name: hardword_redis_data
media_data:
name: hardword_media_data
static_data:
name: hardword_static_data
backend_logs:
name: hardword_backend_logs
celery_logs:
name: hardword_celery_logs
nginx_logs:
name: hardword_nginx_logs
# Custom network
networks:
hardword_network:
name: hardword_network
driver: bridge