version: "3.9"

services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    image: ai-swap-backend:latest
    container_name: ai-swap-backend
    restart: unless-stopped
    ports:
      - "8002:8000"
    environment:
      - PORT=8002
      - UVICORN_WORKERS=2
      - PYTHONUNBUFFERED=1
    volumes:
      - ./backend/logs:/app/backend/logs
      - ./backend/output:/app/backend/output
      - ./backend/data:/app/backend/data
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request,sys;sys.exit(0) if urllib.request.urlopen('http://localhost:8000/health').status==200 else sys.exit(1)"]
      interval: 20s
      timeout: 5s
      retries: 5
      start_period: 20s
