version: '3.9'

services:
  # ── FastAPI Backend ──────────────────────────────────────────────
  backend:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: cv6_backend
    env_file: .env
    ports:
      - "8000:8000"
    volumes:
      - ./logs:/app/logs
      - ./cv6.db:/app/cv6.db
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      - cv6_net

  # ── React Frontend (Nginx) ────────────────────────────────────────
  frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend
    container_name: cv6_frontend
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - /etc/letsencrypt:/etc/letsencrypt:ro   # HTTPS certs (optional)
    depends_on:
      - backend
    restart: unless-stopped
    networks:
      - cv6_net

networks:
  cv6_net:
    driver: bridge

volumes:
  cv6_db:
  cv6_logs:
