Repository navigation
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
396 lines (384 loc) · 12.3 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
396 lines (384 loc) · 12.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
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
services:
# ============================================
# PostgreSQL Database (Backend Service)
# ============================================
postgres:
image: postgres:16-alpine
container_name: lexilingo-postgres
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
mem_limit: 512m
memswap_limit: 512m
environment:
POSTGRES_USER: ${POSTGRES_USER:-lexilingo}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
POSTGRES_DB: ${POSTGRES_DB:-lexilingo}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U lexilingo"]
interval: 10s
timeout: 5s
retries: 5
networks:
- lexilingo-network
# ============================================
# pgAdmin (PostgreSQL Web Management UI)
# ============================================
pgadmin:
image: dpage/pgadmin4
container_name: lexilingo-pgadmin
restart: unless-stopped
deploy:
resources:
limits:
memory: 768M
reservations:
memory: 256M
mem_limit: 768m
memswap_limit: 768m
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-nhthang312@gmail.com}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:?Set PGADMIN_DEFAULT_PASSWORD in .env}
PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION: "True"
PGADMIN_CONFIG_LOGIN_BANNER: "'LexiLingo Database Management'"
ports:
- "5050:80"
depends_on:
postgres:
condition: service_healthy
networks:
- lexilingo-network
# ============================================
# MongoDB Database (AI Service)
# ============================================
mongodb:
image: mongo:7.0
container_name: lexilingo-mongodb
restart: unless-stopped
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 512M
mem_limit: 1g
memswap_limit: 1g
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: lexilingo
volumes:
- mongodb_data:/data/db
- mongodb_config:/data/configdb
- ./ai-service/scripts/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
interval: 10s
timeout: 5s
retries: 5
start_period: 40s
networks:
- lexilingo-network
# ============================================
# Mongo Express (MongoDB Web Management UI)
# ============================================
mongo-express:
image: mongo-express:latest
container_name: lexilingo-mongo-express
restart: unless-stopped
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
mem_limit: 256m
memswap_limit: 256m
environment:
ME_CONFIG_MONGODB_SERVER: mongodb
ME_CONFIG_MONGODB_PORT: 27017
ME_CONFIG_MONGODB_ENABLE_ADMIN: "true"
ME_CONFIG_MONGODB_AUTH_DATABASE: admin
ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_EXPRESS_USER:-admin}
ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_EXPRESS_PASSWORD:?Set MONGO_EXPRESS_PASSWORD in .env}
ports:
- "8081:8081"
depends_on:
mongodb:
condition: service_healthy
networks:
- lexilingo-network
# ============================================
# Redis Cache (Backend)
# ============================================
redis:
image: redis:7-alpine
container_name: lexilingo-redis
restart: unless-stopped
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
mem_limit: 256m
memswap_limit: 256m
command: redis-server --appendonly yes --maxmemory 200mb --maxmemory-policy allkeys-lru
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- lexilingo-network
# ============================================
# Redis Cache (AI Dedicated)
# ============================================
redis-ai:
image: redis:7-alpine
container_name: lexilingo-redis-ai
restart: unless-stopped
deploy:
resources:
limits:
memory: 768M
reservations:
memory: 256M
mem_limit: 768m
memswap_limit: 768m
command: redis-server --appendonly yes --maxmemory 600mb --maxmemory-policy allkeys-lfu
volumes:
- redis_ai_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- lexilingo-network
# ============================================
# RedisInsight (Redis Web Management UI)
# ============================================
redisinsight:
image: redis/redisinsight:latest
container_name: lexilingo-redisinsight
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
mem_limit: 512m
memswap_limit: 512m
ports:
- "8282:5540"
depends_on:
redis:
condition: service_healthy
redis-ai:
condition: service_healthy
networks:
- lexilingo-network
# ============================================
# Backend Service (FastAPI + PostgreSQL)
# ============================================
backend-service:
build:
context: ./backend-service
dockerfile: Dockerfile
container_name: lexilingo-backend-service
restart: unless-stopped
env_file:
- ./backend-service/.env
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 512M
mem_limit: 1g
memswap_limit: 1g
ports:
- "8000:8000"
environment:
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-lexilingo}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-lexilingo}
SECRET_KEY: ${SECRET_KEY:?Set SECRET_KEY in .env}
DEBUG: ${DEBUG:-False}
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:?Set ALLOWED_ORIGINS in .env}
AI_SERVICE_URL: http://ai-service:8001/api/v1
AI_AUDIT_INGEST_SECRET: ${AI_AUDIT_INGEST_SECRET:-}
# Redis (use container hostname, not localhost)
REDIS_URL: redis://redis:6379/0
REDIS_HOST: redis
REDIS_PORT: 6379
# Firebase
FIREBASE_PROJECT_ID: ${FIREBASE_PROJECT_ID:-lexilingo-88492}
FIREBASE_CREDENTIALS_FILE: /app/firebase-service-account.json
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID:-}
GOOGLE_ADMIN_CLIENT_ID: ${GOOGLE_ADMIN_CLIENT_ID:-}
LEARNER_STATE_ENABLED: ${LEARNER_STATE_ENABLED:-false}
LEARNER_STATE_INTERNAL_TOKEN: ${LEARNER_STATE_INTERNAL_TOKEN:-}
LEARNER_STATE_INTERNAL_AUDIENCE: lexilingo-backend
LEARNER_STATE_OUTBOX_BATCH_SIZE: ${LEARNER_STATE_OUTBOX_BATCH_SIZE:-100}
LEXILINGO_PARTNER_API_KEY_HASHES: ${LEXILINGO_PARTNER_API_KEY_HASHES:-}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./backend-service/app:/app/app
- ./backend-service/alembic:/app/alembic
- ./backend-service/firebase-service-account.json:/app/firebase-service-account.json:ro
- ./backend-service/data:/app/data
# The Dockerfile entrypoint applies pending migrations, but Compose's dev
# command overrides it. Keep hot reload while ensuring model changes never
# start against an older schema.
command: >-
sh -c 'alembic upgrade head && exec uvicorn app.main:app --host 0.0.0.0
--port 8000 --reload --proxy-headers --forwarded-allow-ips="*"'
networks:
- lexilingo-network
backend-reminder-worker:
build:
context: ./backend-service
dockerfile: Dockerfile
container_name: lexilingo-reminder-worker
restart: unless-stopped
command: celery -A app.core.celery_app:celery_app worker --loglevel=INFO --concurrency=1
environment:
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-lexilingo}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-lexilingo}
SECRET_KEY: ${SECRET_KEY:?Set SECRET_KEY in .env}
DEBUG: ${DEBUG:-False}
REDIS_URL: redis://redis:6379/0
REMINDERS_ENABLED: ${REMINDERS_ENABLED:-false}
REMINDER_DRY_RUN: ${REMINDER_DRY_RUN:-true}
FIREBASE_PROJECT_ID: ${FIREBASE_PROJECT_ID:-lexilingo-88492}
FIREBASE_CREDENTIALS_FILE: /app/firebase-service-account.json
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./backend-service/app:/app/app
- ./backend-service/alembic:/app/alembic
- ./backend-service/firebase-service-account.json:/app/firebase-service-account.json:ro
healthcheck:
test: ["CMD-SHELL", "celery -A app.core.celery_app:celery_app inspect ping -d celery@$$HOSTNAME --timeout 5 || exit 1"]
interval: 60s
timeout: 10s
retries: 3
start_period: 60s
networks:
- lexilingo-network
backend-reminder-beat:
build:
context: ./backend-service
dockerfile: Dockerfile
container_name: lexilingo-reminder-beat
restart: unless-stopped
command: celery -A app.core.celery_app:celery_app beat --loglevel=INFO
environment:
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-lexilingo}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-lexilingo}
SECRET_KEY: ${SECRET_KEY:?Set SECRET_KEY in .env}
DEBUG: ${DEBUG:-False}
REDIS_URL: redis://redis:6379/0
REMINDERS_ENABLED: ${REMINDERS_ENABLED:-false}
REMINDER_DRY_RUN: ${REMINDER_DRY_RUN:-true}
depends_on:
redis:
condition: service_healthy
volumes:
- ./backend-service/app:/app/app
healthcheck:
test: ["CMD-SHELL", "python -c 'from app.core.celery_status import healthcheck_beat; healthcheck_beat()'"]
interval: 60s
timeout: 10s
retries: 3
start_period: 120s
networks:
- lexilingo-network
# ============================================
# AI Service (FastAPI + MongoDB)
# ============================================
ai-service:
build:
context: ./ai-service
dockerfile: Dockerfile
container_name: lexilingo-ai-service
restart: unless-stopped
deploy:
resources:
limits:
memory: 6G
reservations:
memory: 2G
mem_limit: 6g
memswap_limit: 6g
ports:
- "8001:8001"
environment:
ENVIRONMENT: development
SECRET_KEY: ${SECRET_KEY:?Set SECRET_KEY in .env}
AI_ADMIN_API_KEY: ${AI_ADMIN_API_KEY:?Set AI_ADMIN_API_KEY in .env}
MONGODB_URI: mongodb://mongodb:27017
MONGODB_DATABASE: lexilingo
REDIS_HOST: redis-ai
REDIS_PORT: 6379
REDIS_PASSWORD: ""
REDIS_DB: 0
REDIS_URL: redis://redis-ai:6379/0
GEMINI_API_KEY: ${GEMINI_API_KEY}
GROQ_API_KEYS: ${GROQ_API_KEYS:-}
GROQ_MODEL: ${GROQ_MODEL:-qwen/qwen3.8-27b}
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:?Set ALLOWED_ORIGINS in .env}
CORS_ALLOW_ORIGIN_REGEX: ${AI_CORS_ALLOW_ORIGIN_REGEX:-https?://([a-zA-Z0-9-]+\.)*lexilingo\.me(:\d+)?|https?://(localhost|127\.0\.0\.1)(:\d+)?}
DEBUG: ${DEBUG:-false}
LEARNER_STATE_MODE: ${LEARNER_STATE_MODE:-off}
LEARNER_STATE_API_URL: http://backend-service:8000/api/v1/internal
BACKEND_AUDIT_INGEST_URL: http://backend-service:8000/api/v1/ai-audit/events
AI_AUDIT_INGEST_SECRET: ${AI_AUDIT_INGEST_SECRET:-}
LEARNER_STATE_INTERNAL_TOKEN: ${LEARNER_STATE_INTERNAL_TOKEN:-}
LEARNER_STATE_INTERNAL_AUDIENCE: lexilingo-backend
KUZU_USER_MASTERY_WRITES_ENABLED: ${KUZU_USER_MASTERY_WRITES_ENABLED:-true}
VOICE_DUPLEX_ENABLED: ${VOICE_DUPLEX_ENABLED:-false}
depends_on:
mongodb:
condition: service_healthy
redis-ai:
condition: service_healthy
volumes:
- ./ai-service/api:/app/api
- ./ai-service/data:/app/data
- ./ai-service/models:/app/models
command: uvicorn api.main:app --host 0.0.0.0 --port 8001 --reload
networks:
- lexilingo-network
volumes:
postgres_data:
driver: local
mongodb_data:
driver: local
mongodb_config:
driver: local
redis_data:
driver: local
redis_ai_data:
driver: local
networks:
lexilingo-network:
driver: bridge