# Production compose for end users: MelodyBridge from GHCR plus
# FlareSolverr on one internal network. Start with:  docker compose up -d
# Then open http://localhost:3333 and configure Jellyfin in Settings.

services:
  # Cloudflare solver for the Lucida plugin. Only reachable on the
  # internal compose network, never published to the host. The app
  # finds it automatically by its Docker DNS name on that network.
  flaresolverr:
    image: ghcr.io/flaresolverr/flaresolverr:latest
    container_name: flaresolverr
    environment:
      - LOG_LEVEL=info
      - TZ=Europe/Amsterdam
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://127.0.0.1:8191/health >/dev/null || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s
    security_opt:
      - no-new-privileges:true
    networks:
      - melodybridge

  melodybridge:
    image: ghcr.io/warreth/melodybridge:latest
    container_name: melodybridge
    depends_on:
      flaresolverr:
        condition: service_healthy
    # Reaches a Jellyfin running on the host through this alias.
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "127.0.0.1:3333:80"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://+:80
      - Logging__LogLevel__Default=Information
      - DevPanel__Enabled=false
      - FlareSolverr__Url=auto
      - MELODYBRIDGE_DB=/app/state/melodybridge.db
    # Volumes map a HOST path (left of the colon) to a CONTAINER path
    # (right side). MelodyBridge runs inside the container, so it can
    # only see the container side: every path typed in the app (music
    # folder, Library scan locations, M3U output path) must be the
    # right-hand path, like /music. The left side is where the files
    # really live on your machine; change it to your own folder and
    # keep the right side as is, or the app loses track of the mounts.
    volumes:
      # Downloads land here. In the app: /music (Settings, Default paths).
      - ./data/music:/music
      # M3U playlists are written here. In the app: /app/playlists.
      - ./data/playlists:/app/playlists
      # The SQLite database and runtime state live here, so they
      # survive container rebuilds.
      - ./data/app:/app/state
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - melodybridge

# One explicit network so the app can always resolve the solver by
# its service name, even when the user changes container names.
networks:
  melodybridge:
    name: melodybridge
