-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
331 lines (313 loc) · 8.48 KB
/
docker-compose.yml
File metadata and controls
331 lines (313 loc) · 8.48 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
# Base Docker Compose configuration
# This file defines all services. Use profiles to conditionally start services
# based on .env configuration.
version: '3.8'
services:
# Backend API (always enabled)
backend:
build:
context: ./backend
dockerfile: Dockerfile
args:
ENABLE_MONGODB: ${ENABLE_MONGODB:-false}
ENABLE_NEO4J: ${ENABLE_NEO4J:-false}
ENABLE_CELERY_WORKER: ${ENABLE_CELERY_WORKER:-false}
ENABLE_LLM_OPENAI: ${ENABLE_LLM_OPENAI:-false}
ENABLE_LLM_ANTHROPIC: ${ENABLE_LLM_ANTHROPIC:-false}
ENABLE_LLM_GOOGLE: ${ENABLE_LLM_GOOGLE:-false}
ENABLE_LLM_LITELLM: ${ENABLE_LLM_LITELLM:-false}
ENABLE_LLM_LANGCHAIN: ${ENABLE_LLM_LANGCHAIN:-false}
container_name: backend
restart: unless-stopped
ports:
- "8000:8000"
env_file:
- .env
environment:
- POSTGRES_HOST=postgres
- MONGODB_HOST=mongodb
- NEO4J_HOST=neo4j
- REDIS_HOST=redis
- RABBITMQ_HOST=rabbitmq
- OLLAMA_HOST=${OLLAMA_HOST:-http://ollama:11434}
depends_on:
- postgres
- redis
networks:
- backend-network
- db-network
volumes:
- ./backend:/app
- ${DOCUMENTS_PATH:-./documents}:/documents:ro
# PostgreSQL Database (always enabled)
postgres:
image: pgvector/pgvector:pg16
container_name: postgres
restart: unless-stopped
ports:
- "5432:5432"
environment:
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_DB=${POSTGRES_DB:-app_db}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- db-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache (always enabled, optional via ENABLE_REDIS feature flag)
redis:
image: redis:7-alpine
container_name: redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- db-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# MongoDB (optional - profile: mongodb)
mongodb:
image: mongo:7
container_name: mongodb
restart: unless-stopped
profiles:
- mongodb
ports:
- "27017:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER:-mongo}
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASSWORD:-mongo}
- MONGO_INITDB_DATABASE=${MONGODB_DB:-app_db}
volumes:
- mongodb_data:/data/db
networks:
- db-network
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
interval: 10s
timeout: 5s
retries: 5
# Neo4j Graph Database (optional - profile: neo4j)
neo4j:
image: neo4j:5.15
container_name: neo4j
restart: unless-stopped
profiles:
- neo4j
ports:
- "7474:7474" # HTTP
- "7687:7687" # Bolt
environment:
- NEO4J_AUTH=${NEO4J_USER:-neo4j}/${NEO4J_PASSWORD:-password}
- NEO4J_PLUGINS=["apoc"]
- NEO4J_dbms_security_procedures_unrestricted=apoc.*
volumes:
- neo4j_data:/data
networks:
- db-network
healthcheck:
test: ["CMD-SHELL", "cypher-shell -u neo4j -p password 'RETURN 1'"]
interval: 10s
timeout: 5s
retries: 5
# RabbitMQ Message Broker (optional - profile: rabbitmq)
rabbitmq:
image: rabbitmq:3.12-management-alpine
container_name: rabbitmq
restart: unless-stopped
profiles:
- rabbitmq
ports:
- "5672:5672" # AMQP
- "15672:15672" # Management UI
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_USER:-guest}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD:-guest}
volumes:
- rabbitmq_data:/var/lib/rabbitmq
networks:
- backend-network
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 10s
timeout: 5s
retries: 5
# Ollama (optional - profile: ollama)
ollama:
image: ollama/ollama:latest
container_name: ollama
restart: unless-stopped
profiles:
- ollama
ports:
- "11434:11434"
environment:
- OLLAMA_HOST=0.0.0.0
- OLLAMA_MODELS=${OLLAMA_MODELS:-phi3,nomic-embed-text}
volumes:
- ollama_data:/root/.ollama
networks:
- backend-network
healthcheck:
test: ["CMD", "ollama", "list"]
interval: 30s
timeout: 10s
retries: 5
entrypoint: ["/bin/bash", "-c"]
command:
- |
# Start Ollama server in background
/bin/ollama serve &
# Wait for Ollama to be ready
echo "Waiting for Ollama server..."
until ollama list > /dev/null 2>&1; do sleep 2; done
echo "Ollama server ready"
# Pull models from OLLAMA_MODELS environment variable (comma-separated)
if [ -n "$$OLLAMA_MODELS" ]; then
echo "$$OLLAMA_MODELS" | tr ',' '\n' | while read -r model; do
model=$(echo "$$model" | xargs)
if [ -n "$$model" ]; then
echo "Checking $$model..."
if ! ollama list | grep -q "$$model"; then
echo "Pulling $$model..."
ollama pull "$$model"
else
echo "$$model already exists"
fi
fi
done
else
echo "No models specified in OLLAMA_MODELS"
fi
echo "Ollama initialization complete"
ollama list
# Keep container running
wait
# Celery Worker (optional - profile: celery)
celery-worker:
build:
context: ./backend
dockerfile: Dockerfile.celery
args:
ENABLE_MONGODB: ${ENABLE_MONGODB:-false}
ENABLE_NEO4J: ${ENABLE_NEO4J:-false}
ENABLE_LLM_OPENAI: ${ENABLE_LLM_OPENAI:-false}
ENABLE_LLM_ANTHROPIC: ${ENABLE_LLM_ANTHROPIC:-false}
ENABLE_LLM_GOOGLE: ${ENABLE_LLM_GOOGLE:-false}
ENABLE_LLM_LITELLM: ${ENABLE_LLM_LITELLM:-false}
ENABLE_LLM_LANGCHAIN: ${ENABLE_LLM_LANGCHAIN:-false}
container_name: celery-worker
restart: unless-stopped
profiles:
- celery
env_file:
- .env
environment:
- POSTGRES_HOST=postgres
- MONGODB_HOST=mongodb
- NEO4J_HOST=neo4j
- REDIS_HOST=redis
- RABBITMQ_HOST=rabbitmq
depends_on:
- rabbitmq
- redis
- postgres
networks:
- backend-network
- db-network
volumes:
- ./backend:/app
command: python -m celery -A app.helpers.celery_app worker --loglevel=info
# Celery Beat Scheduler (optional - profile: celery)
celery-beat:
build:
context: ./backend
dockerfile: Dockerfile.celery
args:
ENABLE_MONGODB: ${ENABLE_MONGODB:-false}
ENABLE_NEO4J: ${ENABLE_NEO4J:-false}
ENABLE_LLM_OPENAI: ${ENABLE_LLM_OPENAI:-false}
ENABLE_LLM_ANTHROPIC: ${ENABLE_LLM_ANTHROPIC:-false}
ENABLE_LLM_GOOGLE: ${ENABLE_LLM_GOOGLE:-false}
ENABLE_LLM_LITELLM: ${ENABLE_LLM_LITELLM:-false}
ENABLE_LLM_LANGCHAIN: ${ENABLE_LLM_LANGCHAIN:-false}
container_name: celery-beat
restart: unless-stopped
profiles:
- celery
env_file:
- .env
environment:
- POSTGRES_HOST=postgres
- REDIS_HOST=redis
- RABBITMQ_HOST=rabbitmq
depends_on:
- rabbitmq
- redis
networks:
- backend-network
volumes:
- ./backend:/app
command: python -m celery -A app.helpers.celery_app beat --loglevel=info
# Frontend (optional - profile: frontend)
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: frontend
restart: unless-stopped
profiles:
- frontend
ports:
- "5173:5173"
environment:
- VITE_API_URL=http://localhost:8000/api/v1
networks:
- frontend-network
volumes:
- ./frontend:/app
- /app/node_modules
# Nginx Reverse Proxy (optional - profile: nginx)
nginx:
build:
context: ./nginx
dockerfile: Dockerfile
container_name: nginx
restart: unless-stopped
profiles:
- nginx
ports:
- "80:80"
- "443:443"
depends_on:
- backend
- frontend
networks:
- frontend-network
- backend-network
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
networks:
frontend-network:
driver: bridge
backend-network:
driver: bridge
db-network:
driver: bridge
volumes:
postgres_data:
mongodb_data:
neo4j_data:
redis_data:
rabbitmq_data:
ollama_data: