version: "3.8"

services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: drive-backend
    restart: unless-stopped
    environment:
      - PORT=5827
      - DATA_DIR=/app/data
      - STORAGE_DIR=/storage
      - JWT_SECRET=${JWT_SECRET:-}
      - MAX_LOGIN_ATTEMPTS=5
      - LOCKOUT_SECONDS=300
    volumes:
      # Map to your Unraid cache drive (app data, db, thumbnails)
      - drive-data:/app/data
      # Map to your Unraid HDD array (actual files)
      - drive-storage:/storage
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:5827/health"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s
    networks:
      - drive-net

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: drive-frontend
    restart: unless-stopped
    ports:
      # Change the left side (host port) in Unraid Docker GUI to avoid conflicts
      - "5827:3000"
    environment:
      - API_URL=http://backend:5827
    depends_on:
      backend:
        condition: service_healthy
    networks:
      - drive-net

volumes:
  drive-data:
    driver: local
    # On Unraid, set this to your cache drive path:
    # driver_opts:
    #   type: none
    #   o: bind
    #   device: /mnt/cache/appdata/drive
  drive-storage:
    driver: local
    # On Unraid, set this to your HDD array path:
    # driver_opts:
    #   type: none
    #   o: bind
    #   device: /mnt/user/drive

networks:
  drive-net:
    driver: bridge
