services: postgres: image: postgres:15-alpine container_name: trading-postgres restart: always ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data - ./init_database.sql:/docker-entrypoint-initdb.d/init_database.sql environment: - POSTGRES_DB=tradingdb - POSTGRES_USER=user - POSTGRES_PASSWORD=password healthcheck: test: ["CMD-SHELL", "pg_isready -U user -d tradingdb"] interval: 10s timeout: 5s retries: 5 networks: - trading-net fastapi: build: . container_name: trading-fastapi depends_on: postgres: condition: service_healthy ports: - "8000:8000" environment: - DATABASE_URL=postgresql+asyncpg://user:password@postgres:5432/tradingdb - METRICS_ENABLED=true restart: always healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/system/health', timeout=5)"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - trading-net networks: trading-net: driver: bridge volumes: pgdata: