# Copyparty Docker Compose Configuration
# Deploy with: sudo mkdir -p /opt/docker/copyparty && sudo cp config/docker/copyparty/docker-compose.yml /opt/docker/copyparty/
# Start with: cd /opt/docker/copyparty && sudo docker-compose up -d

# COPYPARTY CONFIGURATION
# - File server with upload/download capabilities
# - WebDAV support for mobile and desktop clients
# - Bound to localhost only (reverse proxy required)
# - Configuration stored in repo at config/copyparty/copyparty.conf

services:
  copyparty:
    image: copyparty/ac:latest
    container_name: copyparty
    restart: unless-stopped

    # Environment
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Budapest

    # Network - bind to localhost for security
    ports:
      - "127.0.0.1:8082:3923"  # Web UI (reverse proxy only)

    # Volume mounts
    volumes:
      # Password database
      - /home/hoborg/.config/copyparty/passwords.json:/home/hoborg/.config/copyparty/passwords.json
      # NAS storage volumes (mapped to container paths)
      - /mnt/nas/shared:/w/shared:rw
      - /mnt/nas/documents:/w/documents:rw
      - /mnt/nas/music:/w/music:rw
      - /mnt/nas/videos:/w/videos:rw
      - /mnt/nas/private:/w/private:rw
      - /mnt/nas/pictures:/w/pictures:rw
      - /mnt/nas/installers:/w/installers:rw
      - /mnt/nas/torrent:/w/torrent:rw

    # Command with inline volume configuration using -v flag
    command:
      - --rp-loc=/files
      - --name=homelab-files
      - --usernames
      - --chpw
      - --chpw-db=/home/hoborg/.config/copyparty/passwords.json
      - --xff-src=172.0.0.0/8
      - --rproxy=-1
      - -e2dsa
      - --dedup
      - --dotpart
      - -a
      - hoborg:AdminPass2024!
      - -a
      - guest:SecurePass2024!
      - -v
      - /w/shared:shared:r:rw,guest:rwmd,hoborg
      - -v
      - /w/documents:documents:rwmd,hoborg
      - -v
      - /w/music:music:r:rw,guest:rwmd,hoborg
      - -v
      - /w/videos:videos:r:rw,guest:rwmd,hoborg
      - -v
      - /w/private:private:rwmd,hoborg
      - -v
      - /w/pictures:pictures:r:rw,guest:rwmd,hoborg
      - -v
      - /w/installers:installers:r:rw,guest:rwmd,hoborg
      - -v
      - /w/torrent:torrent:r:rw,guest:rwmd,hoborg

    # Resource limits
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1G
        reservations:
          cpus: '0.25'
          memory: 256M

    # Health check
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3923/files/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s
