-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
384 lines (369 loc) · 11 KB
/
docker-compose.yml
File metadata and controls
384 lines (369 loc) · 11 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
# ===========================================
# beanllm Playground - Docker Compose
# ===========================================
#
# Profiles:
# (default) : infra only (MongoDB + Redis + Kafka + Zookeeper + Ollama)
# --profile app : + backend + frontend (full stack)
# --profile ui : + Kafka UI + Mongo Express + Redis Commander
# --profile neo4j : + Neo4j graph database
# --profile monitoring : + Streamlit dashboard
#
# Usage:
# docker compose up -d # infra only
# docker compose --profile app up -d # full stack
# docker compose --profile app --profile ui up -d # full stack + admin UIs
# docker compose down -v # stop + remove volumes
#
# ===========================================
x-logging: &default-logging
driver: json-file
options:
max-size: "10m"
max-file: "3"
x-healthcheck-defaults: &healthcheck-defaults
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
services:
# ===========================================
# MongoDB - Chat History & API Keys Storage
# ===========================================
mongodb:
image: mongo:7.0
container_name: beanllm-mongodb
restart: unless-stopped
ports:
- "${MONGO_PORT:-27017}:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USERNAME:-beanllm}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD:-beanllm_secret}
MONGO_INITDB_DATABASE: ${MONGO_DATABASE:-beanllm}
volumes:
- mongodb_data:/data/db
- ./scripts/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
logging: *default-logging
networks:
- beanllm-network
deploy:
resources:
limits:
memory: 512M
# ===========================================
# Redis - Caching, Rate Limiting, Metrics
# ===========================================
redis:
image: redis:7.2-alpine
container_name: beanllm-redis
restart: unless-stopped
ports:
- "${REDIS_PORT:-6379}:6379"
command: >
redis-server
--appendonly yes
--maxmemory ${REDIS_MAX_MEMORY:-256mb}
--maxmemory-policy allkeys-lru
--save 60 1000
--tcp-backlog 511
volumes:
- redis_data:/data
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "redis-cli", "ping"]
logging: *default-logging
networks:
- beanllm-network
deploy:
resources:
limits:
memory: 300M
# ===========================================
# Zookeeper - Kafka Coordination
# ===========================================
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: beanllm-zookeeper
restart: unless-stopped
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_AUTOPURGE_SNAP_RETAIN_COUNT: 3
ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL: 1
volumes:
- zookeeper_data:/var/lib/zookeeper/data
- zookeeper_log:/var/lib/zookeeper/log
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "nc", "-z", "localhost", "2181"]
logging: *default-logging
networks:
- beanllm-network
deploy:
resources:
limits:
memory: 256M
# ===========================================
# Kafka - Event Streaming, Multi-Agent Communication
# ===========================================
kafka:
image: confluentinc/cp-kafka:7.5.0
container_name: beanllm-kafka
restart: unless-stopped
depends_on:
zookeeper:
condition: service_healthy
ports:
- "${KAFKA_PORT:-9092}:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:${KAFKA_PORT:-9092}
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_LOG_RETENTION_HOURS: 168
KAFKA_LOG_RETENTION_BYTES: 1073741824
KAFKA_NUM_PARTITIONS: 3
KAFKA_LOG_CLEANUP_POLICY: delete
volumes:
- kafka_data:/var/lib/kafka/data
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "kafka-topics", "--bootstrap-server", "localhost:9092", "--list"]
interval: 30s
start_period: 60s
logging: *default-logging
networks:
- beanllm-network
deploy:
resources:
limits:
memory: 512M
# ===========================================
# Ollama - Local LLM Server
# ===========================================
ollama:
image: ollama/ollama:latest
container_name: beanllm-ollama
restart: unless-stopped
ports:
- "${OLLAMA_PORT:-11434}:11434"
volumes:
- ollama_data:/root/.ollama
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "curl", "-f", "http://localhost:11434/"]
start_period: 15s
logging: *default-logging
networks:
- beanllm-network
# GPU support: uncomment below for NVIDIA GPU
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all
# capabilities: [gpu]
# ===========================================
# Backend API (profile: app)
# ===========================================
backend:
build:
context: .
dockerfile: playground/backend/Dockerfile
container_name: beanllm-backend
restart: unless-stopped
depends_on:
mongodb:
condition: service_healthy
redis:
condition: service_healthy
kafka:
condition: service_healthy
ollama:
condition: service_healthy
ports:
- "${BACKEND_PORT:-8000}:8000"
env_file:
- playground/backend/.env
environment:
# Override connection strings to use Docker service names
MONGODB_URI: mongodb://${MONGO_ROOT_USERNAME:-beanllm}:${MONGO_ROOT_PASSWORD:-beanllm_secret}@mongodb:27017/${MONGO_DATABASE:-beanllm}?authSource=admin
REDIS_HOST: redis
REDIS_PORT: 6379
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
OLLAMA_HOST: http://ollama:11434
FRONTEND_URL: http://localhost:${FRONTEND_PORT:-3000}
DEPLOYMENT_MODE: docker
volumes:
- backend_uploads:/app/uploads
- backend_chroma:/app/chroma_db
logging: *default-logging
networks:
- beanllm-network
profiles:
- app
deploy:
resources:
limits:
memory: 1G
# ===========================================
# Frontend (profile: app)
# ===========================================
frontend:
build:
context: .
dockerfile: playground/frontend/Dockerfile
args:
NEXT_PUBLIC_API_URL: http://localhost:${BACKEND_PORT:-8000}
container_name: beanllm-frontend
restart: unless-stopped
depends_on:
backend:
condition: service_healthy
ports:
- "${FRONTEND_PORT:-3000}:3000"
environment:
NEXT_PUBLIC_API_URL: http://localhost:${BACKEND_PORT:-8000}
logging: *default-logging
networks:
- beanllm-network
profiles:
- app
deploy:
resources:
limits:
memory: 256M
# ===========================================
# Neo4j - Knowledge Graph (profile: neo4j)
# ===========================================
neo4j:
image: neo4j:5.15-community
container_name: beanllm-neo4j
restart: unless-stopped
ports:
- "${NEO4J_HTTP_PORT:-7474}:7474"
- "${NEO4J_BOLT_PORT:-7687}:7687"
environment:
NEO4J_AUTH: ${NEO4J_USERNAME:-neo4j}/${NEO4J_PASSWORD:-beanllm_secret}
NEO4J_PLUGINS: '["apoc"]'
NEO4J_server_memory_heap_initial__size: 256m
NEO4J_server_memory_heap_max__size: 512m
NEO4J_server_memory_pagecache_size: 256m
volumes:
- neo4j_data:/data
- neo4j_logs:/logs
healthcheck:
<<: *healthcheck-defaults
test: ["CMD-SHELL", "wget -qO- http://localhost:7474 || exit 1"]
start_period: 60s
logging: *default-logging
networks:
- beanllm-network
profiles:
- neo4j
deploy:
resources:
limits:
memory: 1G
# ===========================================
# Kafka UI (profile: ui)
# ===========================================
kafka-ui:
image: provectuslabs/kafka-ui:latest
container_name: beanllm-kafka-ui
restart: unless-stopped
depends_on:
kafka:
condition: service_healthy
ports:
- "${KAFKA_UI_PORT:-8080}:8080"
environment:
KAFKA_CLUSTERS_0_NAME: beanllm-local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:29092
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181
logging: *default-logging
networks:
- beanllm-network
profiles:
- ui
# ===========================================
# Mongo Express (profile: ui)
# ===========================================
mongo-express:
image: mongo-express:1.0.2
container_name: beanllm-mongo-express
restart: unless-stopped
depends_on:
mongodb:
condition: service_healthy
ports:
- "${MONGO_EXPRESS_PORT:-8081}:8081"
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_ROOT_USERNAME:-beanllm}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_ROOT_PASSWORD:-beanllm_secret}
ME_CONFIG_MONGODB_URL: mongodb://${MONGO_ROOT_USERNAME:-beanllm}:${MONGO_ROOT_PASSWORD:-beanllm_secret}@mongodb:27017/
ME_CONFIG_BASICAUTH: "false"
logging: *default-logging
networks:
- beanllm-network
profiles:
- ui
# ===========================================
# Redis Commander (profile: ui)
# ===========================================
redis-commander:
image: rediscommander/redis-commander:latest
container_name: beanllm-redis-commander
restart: unless-stopped
depends_on:
redis:
condition: service_healthy
ports:
- "${REDIS_COMMANDER_PORT:-8082}:8081"
environment:
REDIS_HOSTS: local:redis:6379
logging: *default-logging
networks:
- beanllm-network
profiles:
- ui
# ===========================================
# Networks
# ===========================================
networks:
beanllm-network:
driver: bridge
name: beanllm-network
# ===========================================
# Volumes
# ===========================================
volumes:
mongodb_data:
name: beanllm-mongodb-data
redis_data:
name: beanllm-redis-data
zookeeper_data:
name: beanllm-zookeeper-data
zookeeper_log:
name: beanllm-zookeeper-log
kafka_data:
name: beanllm-kafka-data
ollama_data:
name: beanllm-ollama-data
neo4j_data:
name: beanllm-neo4j-data
neo4j_logs:
name: beanllm-neo4j-logs
backend_uploads:
name: beanllm-backend-uploads
backend_chroma:
name: beanllm-backend-chroma