
services:
  # Backend API Service
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: aegisai-backend
    ports:
      - "8000:8000"
    environment:
      - GEMINI_API_KEY=${GEMINI_API_KEY}
      - API_HOST=0.0.0.0
      - API_PORT=8000
      - VIDEO_SOURCE=0
      - FRAME_SAMPLE_RATE=2
      - DB_PATH=/data/aegis.db
      - EVIDENCE_DIR=/app/evidence
      - LOG_LEVEL=INFO
      - CORS_ORIGINS=["http://localhost:3000"]
    volumes:
      - ./evidence:/app/evidence
      - ./data:/data
      - ./logs:/app/logs
    restart: unless-stopped
    networks:
      - aegisai-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # Frontend Dashboard Service
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      args:
        VITE_GEMINI_API_KEY: ${GEMINI_API_KEY} 
        VITE_API_URL: http://backend:8000
    container_name: aegisai-frontend
    ports:
      - "3000:3000"
    environment:
      - VITE_API_URL=http://backend:8000
    depends_on:
      backend:
        condition: service_healthy
    restart: unless-stopped
    networks:
      - aegisai-network

networks:
  aegisai-network:
    driver: bridge

volumes:
  evidence:
    driver: local
  data:
    driver: local
  logs:
    driver: local
