trading/docker-compose.yml
Viktor Barzin 5a6b20c8f1
fix: resolve 13 important issues from code review
I1: Add graceful shutdown (SIGTERM/SIGINT) to all 5 background services
I2: Fix Dockerfile healthcheck to use curl on /metrics endpoint
I3: Fix StreamConsumer.ensure_group() to only catch BUSYGROUP errors
I4: Fix SimulatedBroker to reject orders with insufficient cash/shares
I5: Move ORM attribute access inside DB session context in trades routes
I6: Add Redis-based rate limiting (10 req/min/IP) on all auth endpoints
I8: Prevent backtest background task garbage collection
I9: Use Numeric(16,6) instead of Float for financial columns in migration
I10: Add index on trades.created_at for time-range queries
I11: Bind infrastructure ports to 127.0.0.1 in docker-compose
I12: Add migrations init service; all app services depend on it
I13: Fix user enumeration in login_begin (return options for non-existent users)
2026-02-22 17:58:01 +00:00

177 lines
4.3 KiB
YAML

services:
# ---------------------------------------------------------------------------
# Infrastructure
# ---------------------------------------------------------------------------
postgres:
image: timescale/timescaledb:latest-pg16
environment:
POSTGRES_USER: trading
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-trading}
POSTGRES_DB: trading
ports:
- "127.0.0.1:5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U trading"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
ports:
- "127.0.0.1:6379:6379"
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
ollama:
image: ollama/ollama:latest
ports:
- "127.0.0.1:11434:11434"
volumes:
- ollama_models:/root/.ollama
# ---------------------------------------------------------------------------
# Database migrations — runs once before application services start
# ---------------------------------------------------------------------------
migrations:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "dev"
SERVICE_MODULE: "api_gateway"
depends_on:
postgres:
condition: service_healthy
env_file: .env
command: python -m alembic upgrade head
restart: "no"
# ---------------------------------------------------------------------------
# Application services
# ---------------------------------------------------------------------------
news-fetcher:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "news"
SERVICE_MODULE: "news_fetcher"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
env_file: .env
restart: unless-stopped
sentiment-analyzer:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "sentiment"
SERVICE_MODULE: "sentiment_analyzer"
depends_on:
redis:
condition: service_healthy
ollama:
condition: service_started
migrations:
condition: service_completed_successfully
env_file: .env
restart: unless-stopped
signal-generator:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "trading"
SERVICE_MODULE: "signal_generator"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
env_file: .env
restart: unless-stopped
trade-executor:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "trading"
SERVICE_MODULE: "trade_executor"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
env_file: .env
restart: unless-stopped
learning-engine:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "trading"
SERVICE_MODULE: "learning_engine"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
env_file: .env
restart: unless-stopped
api-gateway:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "api,trading,backtester"
SERVICE_MODULE: "api_gateway"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
ports:
- "8000:8000"
env_file: .env
restart: unless-stopped
dashboard:
build:
context: .
dockerfile: docker/Dockerfile.dashboard
depends_on:
- api-gateway
ports:
- "3000:80"
restart: unless-stopped
volumes:
pgdata:
redisdata:
ollama_models: