- Remove ~44k LOC of dead code, legacy v1 TS simulator/strategy stack, event-bus, analytics FastAPI prototype, legacy calculation archives, and unused deps (data-ingestion provider API handlers untouched) - Extract @stock-bot/di/http-security and isolate @stock-bot/browser to data-ingestion via ServiceContainerBuilder.withRegistrations() - Harden @stock-bot/mongodb read-only proxies, flatten @stock-bot/postgres with unified master+research migrations, and fix @stock-bot/config EnvLoader, ServiceApplication worker lifecycle, NamespacedCache.clear(), and BatchProcessor error propagation - Flatten workspace root (remove apps/stock/package.json) and collapse orchestrator re-export shims - Pin all Docker image versions, add shm_size/nofile/RAM caps and docker-compose.quant.yml, fix 05-add-visible-column.sql view recreation, and decouple dev/QA Compose project names for side-by-side execution - Update PLATFORM-PLAN, DATA-CONTRACTS (bars_1m PARTITION BY MONTH, Rust bulk ETL, DuckDB limits), MILESTONES, and servers docs
278 lines
7.6 KiB
YAML
278 lines
7.6 KiB
YAML
# QA Infrastructure Stack (existing live volumes: stock-bot_mongodb_data, stock-bot_postgres_data, etc.)
|
|
# WARNING: Do NOT run `docker compose down -v` against this file — mongodb_data holds the full ingested dataset.
|
|
# For isolated local development, use `docker-compose.dev.yml` (ports 5433, 27018, 6380, 9100).
|
|
# Host prerequisite for QuestDB 10.2.0: sysctl vm.max_map_count >= 1048576 (/etc/sysctl.d/99-stockbot.conf)
|
|
name: stock-bot
|
|
|
|
services:
|
|
# Dragonfly - Redis replacement for caching and BullMQ queues
|
|
dragonfly:
|
|
image: docker.dragonflydb.io/dragonflydb/dragonfly:v1.30.3
|
|
container_name: trading-bot-dragonfly
|
|
mem_limit: 5g
|
|
ports:
|
|
- '127.0.0.1:6379:6379'
|
|
command:
|
|
- dragonfly
|
|
- --logtostderr
|
|
- --maxmemory=4gb
|
|
- --proactor_threads=4
|
|
- --bind=0.0.0.0
|
|
- --admin_port=6380
|
|
- --cluster_mode=emulated
|
|
- --hz=500
|
|
- --tcp_keepalive=60
|
|
- --conn_use_incoming_cpu=true
|
|
- --lock_on_hashtags
|
|
- --default_lua_flags=allow-undeclared-keys
|
|
volumes:
|
|
- dragonfly_data:/data
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ['CMD', 'redis-cli', 'ping']
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# PostgreSQL 16.9 - Security master, trial_ledger, backtests, research & vault state
|
|
postgres:
|
|
image: postgres:16.9-alpine
|
|
container_name: trading-bot-postgres
|
|
mem_limit: 10g
|
|
shm_size: 2g
|
|
environment:
|
|
POSTGRES_DB: trading_bot
|
|
POSTGRES_USER: trading_user
|
|
POSTGRES_PASSWORD: trading_pass_dev
|
|
POSTGRES_INITDB_ARGS: '--encoding=UTF-8'
|
|
command:
|
|
- postgres
|
|
- -c
|
|
- shared_buffers=4GB
|
|
- -c
|
|
- effective_cache_size=16GB
|
|
- -c
|
|
- work_mem=64MB
|
|
- -c
|
|
- maintenance_work_mem=1GB
|
|
ports:
|
|
- '127.0.0.1:5432:5432'
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./database/postgres/init:/docker-entrypoint-initdb.d
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ['CMD-SHELL', 'pg_isready -U trading_user -d trading_bot']
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# QuestDB 10.2.0 - Intraday 1m/5m/1h & hot streaming bars (PARTITION BY MONTH)
|
|
questdb:
|
|
image: questdb/questdb:10.2.0
|
|
container_name: trading-bot-questdb
|
|
mem_limit: 28g
|
|
ulimits:
|
|
nofile:
|
|
soft: 1048576
|
|
hard: 1048576
|
|
ports:
|
|
- '127.0.0.1:9000:9000' # Web console & REST
|
|
- '127.0.0.1:8812:8812' # PostgreSQL wire protocol
|
|
- '127.0.0.1:9009:9009' # InfluxDB line protocol
|
|
volumes:
|
|
- questdb_data:/var/lib/questdb
|
|
environment:
|
|
- QDB_TELEMETRY_ENABLED=false
|
|
- QDB_RAM_USAGE_LIMIT_BYTES=21474836480
|
|
- JAVA_OPTS=-Xms2g -Xmx4g
|
|
healthcheck:
|
|
test: ['CMD-SHELL', 'curl -fsS http://127.0.0.1:9003/status >/dev/null 2>&1 || exit 1']
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# MongoDB 7.0.21 - Raw provider corpus (~638 GB; read-only to data-pipeline)
|
|
mongodb:
|
|
image: mongo:7.0.21-jammy
|
|
container_name: trading-bot-mongodb
|
|
mem_limit: 24g
|
|
ulimits:
|
|
nofile:
|
|
soft: 1048576
|
|
hard: 1048576
|
|
environment:
|
|
MONGO_INITDB_ROOT_USERNAME: trading_admin
|
|
MONGO_INITDB_ROOT_PASSWORD: trading_mongo_dev
|
|
MONGO_INITDB_DATABASE: stock
|
|
ports:
|
|
- '127.0.0.1:27017:27017'
|
|
command: --wiredTigerCacheSizeGB ${MONGODB_CACHE_GB:-16}
|
|
volumes:
|
|
- mongodb_data:/data/db
|
|
- ./database/mongodb/init:/docker-entrypoint-initdb.d
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ['CMD', 'mongosh', '--eval', "db.adminCommand('ping')"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# Redis Insight - GUI for Dragonfly debugging
|
|
redis-insight:
|
|
image: redis/redisinsight:2.68
|
|
container_name: trading-bot-redis-insight
|
|
mem_limit: 512m
|
|
ports:
|
|
- '127.0.0.1:8001:5540'
|
|
depends_on:
|
|
- dragonfly
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# PgAdmin - PostgreSQL GUI
|
|
pgadmin:
|
|
image: dpage/pgadmin4:9.4
|
|
container_name: trading-bot-pgadmin
|
|
mem_limit: 768m
|
|
environment:
|
|
PGADMIN_DEFAULT_EMAIL: admin@tradingbot.com
|
|
PGADMIN_DEFAULT_PASSWORD: admin123
|
|
PGADMIN_CONFIG_SERVER_MODE: 'False'
|
|
PGADMIN_DISABLE_POSTFIX: 'true'
|
|
ports:
|
|
- '127.0.0.1:8080:80'
|
|
volumes:
|
|
- pgadmin_data:/var/lib/pgadmin
|
|
depends_on:
|
|
- postgres
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# Mongo Express - MongoDB GUI
|
|
mongo-express:
|
|
image: mongo-express:1.0.2-20-alpine3.19
|
|
container_name: trading-bot-mongo-express
|
|
mem_limit: 512m
|
|
environment:
|
|
ME_CONFIG_MONGODB_ADMINUSERNAME: trading_admin
|
|
ME_CONFIG_MONGODB_ADMINPASSWORD: trading_mongo_dev
|
|
ME_CONFIG_MONGODB_SERVER: mongodb
|
|
ME_CONFIG_MONGODB_PORT: 27017
|
|
ME_CONFIG_BASICAUTH_USERNAME: admin
|
|
ME_CONFIG_BASICAUTH_PASSWORD: admin123
|
|
ports:
|
|
- '127.0.0.1:8081:8081'
|
|
depends_on:
|
|
- mongodb
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# Prometheus - Metrics collection
|
|
prometheus:
|
|
image: prom/prometheus:v3.4.0
|
|
container_name: trading-bot-prometheus
|
|
mem_limit: 1g
|
|
ports:
|
|
- '127.0.0.1:9090:9090'
|
|
volumes:
|
|
- ./monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
- prometheus_data:/prometheus
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--storage.tsdb.retention.time=15d'
|
|
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
- '--web.console.templates=/etc/prometheus/consoles'
|
|
- '--web.enable-lifecycle'
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# Loki - Log aggregation
|
|
loki:
|
|
image: grafana/loki:2.9.2
|
|
container_name: trading-bot-loki
|
|
mem_limit: 768m
|
|
ports:
|
|
- '127.0.0.1:3100:3100'
|
|
volumes:
|
|
- loki_data:/loki
|
|
- ./monitoring/loki:/etc/loki
|
|
command: -config.file=/etc/loki/loki-config.yaml
|
|
healthcheck:
|
|
test: ['CMD', 'wget', '-q', '--spider', 'http://localhost:3100/ready']
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# Grafana - Visualization for logs and metrics
|
|
grafana:
|
|
image: grafana/grafana:10.2.0
|
|
container_name: trading-bot-grafana
|
|
mem_limit: 512m
|
|
ports:
|
|
- '127.0.0.1:3000:3000'
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=admin
|
|
- GF_SECURITY_ADMIN_USER=admin
|
|
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
|
|
- GF_USERS_ALLOW_SIGN_UP=false
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
|
|
depends_on:
|
|
- prometheus
|
|
- loki
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
# Bull Board - Queue monitoring
|
|
bull-board:
|
|
image: venatum/bull-board:3.3.1
|
|
container_name: trading-bot-bull-board
|
|
mem_limit: 256m
|
|
ports:
|
|
- '127.0.0.1:3001:3000'
|
|
environment:
|
|
- REDIS_HOST=dragonfly
|
|
- REDIS_PORT=6379
|
|
- REDIS_PASSWORD=
|
|
- REDIS_DB=0
|
|
- REDIS_URL=redis://dragonfly:6379/0
|
|
depends_on:
|
|
- dragonfly
|
|
restart: unless-stopped
|
|
networks:
|
|
- trading-bot-network
|
|
|
|
volumes:
|
|
postgres_data:
|
|
questdb_data:
|
|
dragonfly_data:
|
|
mongodb_data:
|
|
pgadmin_data:
|
|
prometheus_data:
|
|
grafana_data:
|
|
loki_data:
|
|
|
|
networks:
|
|
trading-bot-network:
|
|
driver: bridge
|