# BREAKING CHANGE (v1.3+): Database volume mount changed from /app/database to /app/data
# If upgrading from a previous version, update your docker-compose.yml:
#   OLD: - soulsync_database:/app/database
#   NEW: - soulsync_database:/app/data
# Your data will be preserved - it's the same volume, just mounted at a different path.

services:
  soulsync:
    image: boulderbadgedad/soulsync:latest
    container_name: soulsync-webui
    environment:
      # User/Group ID configuration
      - PUID=1000
      - PGID=1000
      - UMASK=022
      # Web server configuration
      - PYTHONPATH=/app
      # Optional: Configure through environment variables
      - SOULSYNC_CONFIG_PATH=/app/config/config.json
      # Set timezone (change to your timezone)
      - TZ=America/New_York
      # OAuth callback ports. If 8888/8889 conflict with another container (e.g. Gluetun),
      # change the port numbers below AND update the matching port mappings in the ports section.
      # Then update the redirect URI in SoulSync → Settings → Connections AND in your Spotify/Tidal developer dashboard to match.
      - SOULSYNC_SPOTIFY_CALLBACK_PORT=8888
      - SOULSYNC_TIDAL_CALLBACK_PORT=8889
    ports:
      - "8008:8008"   # Main web app
      - "8888:8888"   # Spotify OAuth callback — keep in sync with SOULSYNC_SPOTIFY_CALLBACK_PORT above
      - "8889:8889"   # Tidal OAuth callback   — keep in sync with SOULSYNC_TIDAL_CALLBACK_PORT above
    volumes:
      # Persistent data volumes
      - ./config:/app/config
      - ./logs:/app/logs
      - ./downloads:/app/downloads
      - ./Staging:/app/Staging
      - ./MusicVideos:/app/MusicVideos
      - ./scripts:/app/scripts
      # Use named volume for database persistence (separate from host database)
      # NOTE: Changed from /app/database to /app/data to avoid overwriting Python package
      - soulsync_database:/app/data
      # IMPORTANT: Mount host paths that your input/output folders live on.
      # Replace these examples with your actual paths:
      #   Linux/Mac:  - /path/to/your/downloads:/host/downloads:rw
      #   WSL:        - /mnt/d/Music:/host/music:rw
      # You can add as many mounts as needed for your setup.
      # - /path/to/downloads:/host/downloads:rw
      # - /path/to/music-library:/host/music:rw
      # Optional: Mount your music library for Plex/Jellyfin/Navidrome access
      # - /path/to/your/music:/music:ro
      #
      # ─── Torrent / Usenet download sources (Prowlarr integration) ────────
      # If you use the Torrent Only or Usenet Only download sources, SoulSync
      # needs to read the files your torrent / usenet client downloads.
      #
      # EASIEST SETUP: point qBittorrent, SABnzbd / NZBGet, AND slskd at the
      # SAME download folder. The ./downloads mount above is reused; nothing
      # new to add here. Just configure each client's download path to
      # /downloads (inside its own container) — files land in the same place
      # SoulSync already reads from.
      #
      # SEPARATE FOLDERS (if you prefer): uncomment + edit these to point at
      # the client's download folder. The in-container path must MATCH the
      # save_path the client reports.
      # - /path/to/qbittorrent/downloads:/downloads/torrents:rw
      # - /path/to/sabnzbd/complete:/downloads/usenet:rw
      # Then set the torrent client's save path to /downloads/torrents and
      # SAB / NZBGet's complete folder to /downloads/usenet (or whatever
      # in-container path you chose). Skip these if your downloader runs
      # outside Docker and writes to a path already mounted above.
    extra_hosts:
      # Allow container to reach host services
      - "host.docker.internal:host-gateway"
    restart: unless-stopped
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8008/" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    # Resource limits (adjust as needed)
    deploy:
      resources:
        limits:
          cpus: '2.0'
          memory: 2G
        reservations:
          cpus: '0.5'
          memory: 512M

  ## ─── Optional: slskd (Soulseek client) ───────────────────────────────
  ## Uncomment below to run slskd alongside SoulSync.
  ## Downloads land in ./downloads which SoulSync already reads from.
  ## After starting, set your SoulSync slskd URL to http://slskd:5030
  ## and the API key to whatever you set in SLSKD_API_KEY below.
  #
  # slskd:
  #   image: slskd/slskd:latest
  #   container_name: slskd
  #   environment:
  #     - SLSKD_REMOTE_CONFIGURATION=true
  #     - SLSKD_API_KEY=your-api-key-here
  #     - TZ=America/New_York
  #   ports:
  #     - "5030:5030"
  #   volumes:
  #     - ./slskd-data:/app
  #     - ./downloads:/app/downloads
  #   restart: unless-stopped

# Named volumes for persistent data
volumes:
  soulsync_database:
    driver: local

# Optional: Add external network for communication with other containers
networks:
  default:
    name: soulsync-network
