# APPNICENAME=Stash
# APPDESCRIPTION=An organizer for your porn, written in Go

services:
  stash:
    build:
      context: .
      dockerfile: dockerfile.stash
    container_name: stash
    restart: unless-stopped

    # Match the container’s exposed port with the internal Stash port
    ports:
      - "9999:9999"

    # Optional: for DLNA (comment ports above and uncomment this)
    # network_mode: host

    # Resource limits
    cpus: "4.0"
    mem_limit: 8g

    environment:
      # Stash internal paths
      - STASH_STASH=/data/
      - STASH_GENERATED=/generated/
      - STASH_METADATA=/metadata/
      - STASH_CACHE=/cache/
      - STASH_PORT=9999

      # Run as root (can adjust later if needed)
      - PUID=1000
      - PGID=1000

      # Optional — enable headless Chromium for scrapers
      - CHROME_PATH=/usr/bin/chromium
      - STASH_BROWSER=chromium

    volumes:
      - /etc/localtime:/etc/localtime:ro

      # Persistent Stash app data
      - /db/stash:/root/.stash
      - /pool/docker/stash/data/data:/data
      - /pool/docker/stash/data/metadata:/metadata
      - /pool/docker/stash/data/cache:/cache
      - /pool/docker/stash/data/blobs:/blobs
      - /pool/docker/stash/data/generated:/generated

      # Media mounts (your library)
      - /pool/other:/media
    labels:
      - "traefik.enable=true"
      - "wud.ignore=true"

      # Router
      - "traefik.http.routers.stash.rule=Host(`stash.mapletree.email`)"
      - "traefik.http.routers.stash.entrypoints=web,websecure"
      - "traefik.http.routers.stash.tls.certresolver=myresolver"

      # Service (points to internal port)
      - "traefik.http.services.stash.loadbalancer.server.port=9999"

    networks:
      - web
    logging:
      driver: "json-file"
      options:
        max-file: "10"
        max-size: "2m"

networks:
  web:
    external: true