trading/docker-compose.yml

181 lines
4.3 KiB
YAML
Raw Normal View History

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
# ---------------------------------------------------------------------------
# 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
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
market-data:
build:
context: .
dockerfile: docker/Dockerfile.service
args:
EXTRAS: "trading"
SERVICE_MODULE: "market_data"
depends_on:
redis:
condition: service_healthy
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: