# Coolify-compatible docker-compose.yml
# No port bindings - Coolify handles routing via Traefik reverse proxy

services:
  backend:
    build: ./backend
    container_name: h2h-backend
    restart: unless-stopped
    environment:
      - DATABASE_URL=sqlite+aiosqlite:///./data/h2h.db
      - JWT_SECRET=${JWT_SECRET}
      - JWT_ALGORITHM=HS256
      - ACCESS_TOKEN_EXPIRE_MINUTES=30
      - REFRESH_TOKEN_EXPIRE_DAYS=7
    volumes:
      - sqlite_data:/app/data
    command: uvicorn app.main:app --host 0.0.0.0 --port 8000
    expose:
      - "8000"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/docs"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  frontend:
    build: ./frontend
    container_name: h2h-frontend
    restart: unless-stopped
    environment:
      - VITE_API_URL=${VITE_API_URL}
      - VITE_WS_URL=${VITE_WS_URL}
    depends_on:
      backend:
        condition: service_healthy
    command: npm run build && npx serve -s dist -l 5173
    expose:
      - "5173"
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:5173"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

volumes:
  sqlite_data:
