Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
207 lines (200 loc) · 7.19 KB
/
Copy pathdocker-compose.yml
File metadata and controls
207 lines (200 loc) · 7.19 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
services:
# PostgreSQL database
# PRODUCTION: Use strong password via POSTGRES_PASSWORD env var instead of "postgres"
# PRODUCTION: Use managed database service (e.g., Railway, Supabase) instead of self-hosted
postgres:
image: pgvector/pgvector:pg15
container_name: rag_transcript_postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-rag_transcript}
# SECURITY: Ports commented out to prevent external access - only accessible via Docker internal network
# Uncomment for local development if you need direct database access:
# ports:
# - "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
# Redis (Celery broker/backend)
# PRODUCTION: Set strong REDIS_PASSWORD env var
redis:
image: redis:7.4.7-alpine
container_name: rag_transcript_redis
command: redis-server --requirepass ${REDIS_PASSWORD:-changeme}
# SECURITY: Ports commented out to prevent external access - only accessible via Docker internal network
# Uncomment for local development if you need direct Redis access:
# ports:
# - "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "--no-auth-warning", "-a", "${REDIS_PASSWORD:-changeme}", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Qdrant vector database
# PRODUCTION: Set strong QDRANT_API_KEY env var
qdrant:
image: qdrant/qdrant:v1.16.3
container_name: rag_transcript_qdrant
environment:
- QDRANT__SERVICE__API_KEY=${QDRANT_API_KEY:-changeme}
ports:
- "6333:6333" # HTTP API
- "6334:6334" # gRPC
volumes:
- qdrant_data:/qdrant/storage
# Healthcheck disabled - Qdrant doesn't include curl/wget in container
# healthcheck:
# test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:6333/healthz || exit 1"]
# interval: 10s
# timeout: 5s
# retries: 5
# FastAPI application
app:
build:
context: ./backend
dockerfile: Dockerfile
container_name: rag_transcript_app
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
env_file:
- ./backend/.env
volumes:
- ./backend:/app
- ./storage:/app/storage # Local storage volume
- ./hf_cache:/root/.cache/huggingface # Pre-downloaded HF models
- ./whisper_cache:/root/.cache/whisper # Pre-downloaded Whisper models
ports:
- "8000:8000"
environment:
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/rag_transcript
- REDIS_URL=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- QDRANT_HOST=qdrant
- QDRANT_PORT=6333
- QDRANT_API_KEY=${QDRANT_API_KEY:-changeme}
- STORAGE_BACKEND=local
- LOCAL_STORAGE_PATH=/app/storage
- EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
- HF_HOME=/root/.cache/huggingface
- TRANSFORMERS_CACHE=/root/.cache/huggingface
- SENTENCE_TRANSFORMERS_HOME=/root/.cache/huggingface
- HF_HUB_OFFLINE=0
- TRANSFORMERS_OFFLINE=0
- PYTHONUNBUFFERED=1
- ENVIRONMENT=${ENVIRONMENT:-development}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
qdrant:
condition: service_started
# Celery worker
worker:
build:
context: ./backend
dockerfile: Dockerfile
container_name: rag_transcript_worker
command: celery -A app.core.celery_app worker --loglevel=info --concurrency=1 --pool=solo
env_file:
- ./backend/.env
volumes:
- ./backend:/app
- ./storage:/app/storage
- ./hf_cache:/root/.cache/huggingface # Pre-downloaded HF models
- ./whisper_cache:/root/.cache/whisper # Pre-downloaded Whisper models
- ./cookies.txt:/etc/yt-cookies.txt # YouTube cookies for anti-bot auth (optional)
environment:
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/rag_transcript
- REDIS_URL=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- QDRANT_HOST=qdrant
- QDRANT_PORT=6333
- QDRANT_API_KEY=${QDRANT_API_KEY:-changeme}
- STORAGE_BACKEND=local
- LOCAL_STORAGE_PATH=/app/storage
- EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
- HF_HOME=/root/.cache/huggingface
- TRANSFORMERS_CACHE=/root/.cache/huggingface
- SENTENCE_TRANSFORMERS_HOME=/root/.cache/huggingface
- HF_HUB_OFFLINE=0
- TRANSFORMERS_OFFLINE=0
- PYTHONUNBUFFERED=1
- ENVIRONMENT=${ENVIRONMENT:-development}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
qdrant:
condition: service_started
restart: on-failure:3
# Celery beat (scheduled tasks)
beat:
build:
context: ./backend
dockerfile: Dockerfile
container_name: rag_transcript_beat
command: celery -A app.core.celery_app beat --loglevel=info
env_file:
- ./backend/.env
volumes:
- ./backend:/app
- ./hf_cache:/root/.cache/huggingface # Pre-downloaded HF models
- ./whisper_cache:/root/.cache/whisper # Pre-downloaded Whisper models
environment:
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/rag_transcript
- REDIS_URL=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0
- EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
- HF_HOME=/root/.cache/huggingface
- TRANSFORMERS_CACHE=/root/.cache/huggingface
- SENTENCE_TRANSFORMERS_HOME=/root/.cache/huggingface
- HF_HUB_OFFLINE=0
- TRANSFORMERS_OFFLINE=0
- PYTHONUNBUFFERED=1
- ENVIRONMENT=${ENVIRONMENT:-development}
depends_on:
- redis
restart: on-failure:3
healthcheck:
test: ["CMD-SHELL", "celery -A app.core.celery_app inspect ping 2>/dev/null | grep -q 'OK' || ps aux | grep -q '[c]elery.*beat'"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# Next.js frontend
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: rag_transcript_frontend
command: npm run dev
env_file:
- ./frontend/.env
volumes:
- ./frontend:/app
- /app/node_modules # Preserve container's node_modules
- /app/.next # Preserve build cache
ports:
- "3000:3000"
environment:
- NEXT_PUBLIC_API_URL=http://localhost:8000
- NEXT_PUBLIC_API_V1_PREFIX=/api/v1
- BACKEND_INTERNAL_URL=http://app:8000
- WATCHPACK_POLLING=true # Enable hot reload in Docker
depends_on:
- app
volumes:
postgres_data:
redis_data:
qdrant_data: