-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
552 lines (526 loc) · 16.3 KB
/
docker-compose.yml
File metadata and controls
552 lines (526 loc) · 16.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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# QuantStack LangGraph Stack
# All services start with `docker compose up -d` — no profiles, no optional services.
#
# Services:
# Infrastructure: postgres (pgvector), langfuse-db, langfuse, ollama
# Graphs: trading-graph, research-graph, supervisor-graph
# ML: finrl-worker (torch + RL, separate image)
#
# Usage:
# docker compose up -d # Start everything
# docker compose logs -f trading-graph # Follow trading graph logs
# docker compose down # Stop everything
# docker compose down -v # Stop and delete data volumes
#
# Secrets: copy .env.example -> .env and fill in values.
# Shared bind mounts for all graph services.
# Host paths → container paths — models, logs, memory, and execution state
# persist across rebuilds and restarts.
x-graph-volumes: &graph-volumes
- ./src:/app/src # Live source code (no rebuild needed)
- ./scripts:/app/scripts # Runner scripts
- ./models:/app/models # ML model checkpoints (joblib, pkl)
- ./data:/app/data # Market data cache, DuckDB files
- ./logs:/app/logs # Application logs (trader.log)
- ./.claude/memory:/app/.claude/memory # Trade journal, workshop lessons
- ~/.quantstack:/home/quantstack/.quantstack # Kill switch, drift baselines, FinRL, Qdrant, structured logs
services:
# ── Infrastructure ──────────────────────────────────────────────────────────
postgres:
image: pgvector/pgvector:pg16
container_name: quantstack-postgres
ports:
- "127.0.0.1:5434:5432"
environment:
POSTGRES_DB: quantstack
POSTGRES_USER: quantstack
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres-data:/var/lib/postgresql/data
- quantstack-backups:/data/quantstack/backups
- quantstack-wal-archive:/data/quantstack/wal_archive
healthcheck:
test: ["CMD-SHELL", "pg_isready -U quantstack"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
mem_limit: 512m
memswap_limit: 512m
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
langfuse-db:
image: postgres:16-alpine
container_name: quantstack-langfuse-db
environment:
POSTGRES_DB: langfuse
POSTGRES_USER: langfuse
POSTGRES_PASSWORD: ${LANGFUSE_DB_PASSWORD}
volumes:
- langfuse-db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U langfuse"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
mem_limit: 256m
memswap_limit: 256m
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
ollama:
image: ollama/ollama
container_name: quantstack-ollama
ports:
- "127.0.0.1:11434:11434"
volumes:
- ollama-data:/root/.ollama
healthcheck:
test: ["CMD-SHELL", "ollama list >/dev/null 2>&1 || exit 1"]
interval: 15s
timeout: 10s
retries: 5
start_period: 30s
mem_limit: 4g
memswap_limit: 4g
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
langfuse:
image: langfuse/langfuse:2
container_name: quantstack-langfuse
ports:
- "127.0.0.1:3100:3000"
depends_on:
langfuse-db:
condition: service_healthy
environment:
DATABASE_URL: postgresql://langfuse:${LANGFUSE_DB_PASSWORD}@langfuse-db:5432/langfuse
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:-change-me-random-secret}
SALT: ${SALT:-change-me-random-salt}
NEXTAUTH_URL: http://localhost:3000
LANGFUSE_INIT_ORG_ID: quantstack
LANGFUSE_INIT_ORG_NAME: QuantStack
LANGFUSE_INIT_PROJECT_ID: trading
LANGFUSE_INIT_PROJECT_NAME: Trading
LANGFUSE_INIT_PROJECT_PUBLIC_KEY: ${LANGFUSE_PUBLIC_KEY:-pk-lf-quantstack-local}
LANGFUSE_INIT_PROJECT_SECRET_KEY: ${LANGFUSE_SECRET_KEY:-sk-lf-quantstack-local}
LANGFUSE_INIT_USER_EMAIL: admin@quantstack.local
LANGFUSE_INIT_USER_NAME: quantstack
LANGFUSE_INIT_USER_PASSWORD: ${LANGFUSE_INIT_USER_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "wget -q --spider http://$(hostname -i):3000/api/public/health || exit 1"]
interval: 15s
timeout: 10s
retries: 5
start_period: 30s
mem_limit: 512m
memswap_limit: 512m
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
# ── LiteLLM Proxy ────────────────────────────────────────────────────────────
litellm:
image: ghcr.io/berriai/litellm:main-latest
container_name: quantstack-litellm
command: ["--config", "/app/config.yaml", "--port", "4000"]
ports:
- "127.0.0.1:4000:4000"
volumes:
- ./litellm_config.yaml:/app/config.yaml:ro
- ~/.zscaler_certifi_bundle.pem:/etc/ssl/certs/zscaler.pem:ro
env_file:
- path: .env
required: false
environment:
SSL_CERT_FILE: /etc/ssl/certs/zscaler.pem
REQUESTS_CA_BUNDLE: /etc/ssl/certs/zscaler.pem
OLLAMA_API_BASE: http://ollama:11434
LANGFUSE_HOST: http://langfuse:3000
LANGFUSE_PUBLIC_KEY: ${LANGFUSE_PUBLIC_KEY:-}
LANGFUSE_SECRET_KEY: ${LANGFUSE_SECRET_KEY:-}
LITELLM_MASTER_KEY: ${LITELLM_MASTER_KEY:-}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000/health"]
interval: 15s
timeout: 10s
retries: 5
start_period: 30s
mem_limit: 512m
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "3"
# ── Graph Services ───────────────────────────────────────────────────────────
trading-graph:
build:
context: .
dockerfile: Dockerfile
container_name: quantstack-trading-graph
init: true
command: ["python", "-m", "quantstack.runners.trading_runner"]
depends_on:
ollama:
condition: service_healthy
langfuse:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- path: .env
required: false
environment:
TRADER_PG_URL: ${TRADER_PG_URL:-postgresql://${USER}@host.docker.internal:5432/quantstack}
EXEC_MONITOR_POLL_INTERVAL: ${EXEC_MONITOR_POLL_INTERVAL:-5}
EXEC_MONITOR_RECONCILE_INTERVAL: ${EXEC_MONITOR_RECONCILE_INTERVAL:-60}
EXEC_MONITOR_QUOTE_FEED: ${EXEC_MONITOR_QUOTE_FEED:-auto}
EXEC_MONITOR_SHADOW_MODE: ${EXEC_MONITOR_SHADOW_MODE:-true}
LITELLM_PROXY_URL: ${LITELLM_PROXY_URL:-}
volumes: *graph-volumes
healthcheck:
test: ["CMD", "python", "-c", "from quantstack.health.heartbeat import check_health; check_health('trading')"]
interval: 60s
timeout: 15s
retries: 3
start_period: 120s
mem_limit: 1g
memswap_limit: 1g
stop_grace_period: 90s
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
research-graph:
build:
context: .
dockerfile: Dockerfile
container_name: quantstack-research-graph
init: true
command: ["python", "-m", "quantstack.runners.research_runner"]
depends_on:
ollama:
condition: service_healthy
langfuse:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- path: .env
required: false
environment:
TRADER_PG_URL: ${TRADER_PG_URL:-postgresql://${USER}@host.docker.internal:5432/quantstack}
LITELLM_PROXY_URL: ${LITELLM_PROXY_URL:-}
volumes: *graph-volumes
healthcheck:
test: ["CMD", "python", "-c", "from quantstack.health.heartbeat import check_health; check_health('research')"]
interval: 60s
timeout: 15s
retries: 3
start_period: 120s
mem_limit: 1g
memswap_limit: 1g
stop_grace_period: 90s
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
supervisor-graph:
build:
context: .
dockerfile: Dockerfile
container_name: quantstack-supervisor-graph
init: true
command: ["python", "-m", "quantstack.runners.supervisor_runner"]
depends_on:
ollama:
condition: service_healthy
langfuse:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- path: .env
required: false
environment:
TRADER_PG_URL: ${TRADER_PG_URL:-postgresql://${USER}@host.docker.internal:5432/quantstack}
LITELLM_PROXY_URL: ${LITELLM_PROXY_URL:-}
volumes: *graph-volumes
healthcheck:
test: ["CMD", "python", "-c", "from quantstack.health.heartbeat import check_health; check_health('supervisor')"]
interval: 60s
timeout: 15s
retries: 3
start_period: 120s
mem_limit: 512m
memswap_limit: 512m
stop_grace_period: 90s
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
# ── Dashboard (real-time agent chat windows) ─────────────────────────────────
dashboard:
build:
context: .
dockerfile: Dockerfile
container_name: quantstack-dashboard
init: true
command: ["python", "-m", "quantstack.dashboard.app"]
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- path: .env
required: false
environment:
TRADER_PG_URL: ${TRADER_PG_URL:-postgresql://${USER}@host.docker.internal:5432/quantstack}
ports:
- "127.0.0.1:8421:8421"
healthcheck:
test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8421/api/status')\" 2>/dev/null || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
mem_limit: 256m
memswap_limit: 256m
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
# ── Scheduler (deterministic cron jobs, no LLM) ─────────────────────────────
scheduler:
build:
context: .
dockerfile: Dockerfile
container_name: quantstack-scheduler
init: true
command: ["python", "scripts/scheduler.py"]
depends_on:
postgres:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- path: .env
required: false
environment:
TRADER_PG_URL: ${TRADER_PG_URL:-postgresql://${USER}@host.docker.internal:5432/quantstack}
ports:
- "127.0.0.1:8422:8422"
volumes: *graph-volumes
healthcheck:
test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8422/health')\" 2>/dev/null || exit 1"]
interval: 60s
timeout: 15s
retries: 3
start_period: 30s
mem_limit: 512m
memswap_limit: 512m
stop_grace_period: 120s
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
# ── FinRL Worker (torch + RL, separate image to avoid 4GB bloat) ────────────
finrl-worker:
build:
context: .
dockerfile: Dockerfile.finrl
container_name: quantstack-finrl-worker
init: true
command: ["python", "-m", "quantstack.finrl.server"]
depends_on:
langfuse:
condition: service_healthy
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- path: .env
required: false
environment:
TRADER_PG_URL: ${TRADER_PG_URL:-postgresql://${USER}@host.docker.internal:5432/quantstack}
FINRL_TRANSPORT: sse
FINRL_PORT: "8090"
ports:
- "127.0.0.1:8090:8090"
volumes: *graph-volumes
healthcheck:
test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8090/sse')\" 2>/dev/null || exit 0"]
interval: 60s
timeout: 10s
retries: 3
start_period: 60s
mem_limit: 2g
memswap_limit: 2g
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
# =========================================================================
# Observability: Log Aggregation + Monitoring
# =========================================================================
loki:
image: grafana/loki:3.1.0
volumes:
- ./config/loki/loki-config.yaml:/etc/loki/loki-config.yaml:ro
- loki-data:/loki
command: -config.file=/etc/loki/loki-config.yaml
ports:
- "3101:3100"
mem_limit: 256m
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3100/ready"]
interval: 15s
timeout: 5s
retries: 3
restart: unless-stopped
networks:
- quantstack-net
fluent-bit:
image: fluent/fluent-bit:3.1
volumes:
# On macOS (Docker Desktop), /var/lib/docker/containers is inside the VM
# and is accessible from containers. On native Linux, it maps directly.
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- ./config/fluent-bit/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf:ro
- ./config/fluent-bit/parsers.conf:/fluent-bit/etc/parsers.conf:ro
depends_on:
- loki
mem_limit: 64m
restart: unless-stopped
networks:
- quantstack-net
grafana:
image: grafana/grafana:11.1.0
volumes:
- ./config/grafana/provisioning:/etc/grafana/provisioning:ro
- grafana-data:/var/lib/grafana
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_ALERTING_ENABLED=true
- DISCORD_WEBHOOK_URL # injected from host env
ports:
- "3000:3000"
depends_on:
- loki
mem_limit: 256m
restart: unless-stopped
networks:
- quantstack-net
# cAdvisor: container CPU, memory, OOM metrics.
# On macOS Docker Desktop, some CPU metrics may differ from native Linux.
cadvisor:
image: gcr.io/cadvisor/cadvisor:v0.49.1
container_name: quantstack-cadvisor
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
ports:
- "127.0.0.1:8080:8080"
mem_limit: 128m
memswap_limit: 128m
restart: unless-stopped
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
prometheus:
image: prom/prometheus:v2.53.0
container_name: quantstack-prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.retention.time=15d"
- "--web.enable-lifecycle"
volumes:
- ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
ports:
- "127.0.0.1:9090:9090"
mem_limit: 256m
memswap_limit: 256m
restart: unless-stopped
depends_on:
cadvisor:
condition: service_started
networks:
- quantstack-net
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
volumes:
postgres-data:
driver: local
langfuse-db-data:
driver: local
ollama-data:
driver: local
loki-data:
driver: local
grafana-data:
driver: local
prometheus-data:
driver: local
quantstack-backups:
driver: local
quantstack-wal-archive:
driver: local
networks:
quantstack-net:
driver: bridge