version: '3.8'

services:
  nextav:
    build: 
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    volumes:
      - ./data:/app/data
      - ./media:/app/media
    environment:
      - NODE_ENV=production
      - DATABASE_URL=file:/app/data/nextav.db
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    depends_on:
      - ffmpeg

  # FFmpeg service for thumbnail generation (optional - can use host FFmpeg)
  ffmpeg:
    image: jrottenberg/ffmpeg:4.4-alpine
    volumes:
      - ./media:/media:ro
    command: tail -f /dev/null  # Keep container running
    restart: unless-stopped

  # Nginx reverse proxy (optional for production)
  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./ssl:/etc/nginx/ssl:ro
    depends_on:
      - nextav
    restart: unless-stopped
    profiles:
      - production

volumes:
  nextav_data:
    driver: local
  nextav_media:
    driver: local

networks:
  default:
    name: nextav-network