version: "3.9" services: # ── PostgreSQL Database ────────────────────────────────────────────── postgres: image: postgres:16-alpine container_name: autoflow-db restart: unless-stopped ports: - "5432:5432" environment: POSTGRES_USER: autoflow POSTGRES_PASSWORD: autoflow POSTGRES_DB: autoflow volumes: - postgres_data:/var/lib/postgresql/data - ./backend/app/migrations/init.sql:/docker-entrypoint-initdb.d/init.sql healthcheck: test: ["CMD-SHELL", "pg_isready -U autoflow -d autoflow"] interval: 10s timeout: 5s retries: 5 start_period: 30s # ── Redis Cache ───────────────────────────────────────────────────── redis: image: redis:7-alpine container_name: autoflow-redis restart: unless-stopped ports: - "6379:6379" volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 3s retries: 5 # ── AutoFlow API Backend ──────────────────────────────────────────── api: build: context: . dockerfile: backend/Dockerfile container_name: autoflow-api restart: unless-stopped ports: - "8000:8000" environment: DATABASE_URL: "postgresql+asyncpg://autoflow:autoflow@postgres:5432/autoflow" DATABASE_URL_SYNC: "postgresql+psycopg2://autoflow:autoflow@postgres:5432/autoflow" REDIS_URL: "redis://redis:6379/0" CORS_ORIGINS: "http://localhost:3000,http://localhost:5173" LOG_LEVEL: "INFO" DEBUG: "false" SECRET_KEY: "autoflow-production-secret-key-change-me" depends_on: postgres: condition: service_healthy redis: condition: service_healthy command: > sh -c " python -c 'from app.database import engine; import asyncio; from app.database import Base; from sqlalchemy import text; loop = asyncio.get_event_loop(); loop.run_until_complete(engine.connect())' && python -m app.seed_data && uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 2 " # ── Frontend (placeholder/seed) ────────────────────────────────────── # Uncomment and configure when frontend is ready # frontend: # build: # context: ./frontend # dockerfile: Dockerfile # container_name: autoflow-frontend # restart: unless-stopped # ports: # - "3000:3000" # environment: # NEXT_PUBLIC_API_URL: "http://localhost:8000" # NEXT_PUBLIC_WS_URL: "ws://localhost:8000" # depends_on: # - api volumes: postgres_data: name: autoflow_postgres_data redis_data: name: autoflow_redis_data