version: "3.8"

services:
  backend:
    build:
      context: .
      dockerfile: backend/Dockerfile
    network_mode: "container:gluetun"
    environment:
      PORT: "8084"
      DATABASE_URL: ${DATABASE_URL:-postgres://bear:bear123@postgres-shared:5432/umm?sslmode=disable}
      QDRANT_URL: ${QDRANT_URL:-http://qdrant:6333}
      OLLAMA_URL: ${OLLAMA_URL:-http://192.168.50.84:11434}
      FRONTEND_URL: ${FRONTEND_URL:-http://umm.local.tophermayor.com}
      ADMIN_API_KEY: ${ADMIN_API_KEY:-03136aebde4bd783ae6ada1abdc8debbd11e3fe89380d87d}
      TMDB_API_KEY: ${TMDB_API_KEY:-}
      DOWNLOAD_DIR: /data/completed
    volumes:
      - /mnt/truenas/mediadata:/data
      # Arr SQLite databases for migration (read-only)
      - /home/bear/homelab/ubuntu/media-stack/sonarr:/data/arr-configs/sonarr:ro
      - /home/bear/homelab/ubuntu/media-stack/radarr:/data/arr-configs/radarr:ro
      - /home/bear/homelab/ubuntu/media-stack/sonarr-anime:/data/arr-configs/sonarr-anime:ro
      - /home/bear/homelab/ubuntu/media-stack/radarr-anime:/data/arr-configs/radarr-anime:ro
      - /home/bear/homelab/ubuntu/media-stack/lidarr:/data/arr-configs/lidarr:ro
      - /home/bear/homelab/ubuntu/media-stack/readarr:/data/arr-configs/readarr:ro
      - /home/bear/homelab/ubuntu/media-stack/prowlarr:/data/arr-configs/prowlarr:ro
    restart: unless-stopped
    depends_on:
      - frontend

  frontend:
    build:
      context: frontend
      dockerfile: Dockerfile
    environment:
      VITE_API_URL: ${VITE_API_URL:-http://umm.local.tophermayor.com}
    networks:
      - proxy-net
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.umm.rule=Host(`umm.local.tophermayor.com`)"
      - "traefik.http.routers.umm.entrypoints=websecure"
      - "traefik.http.services.umm.loadbalancer.server.port=3000"

networks:
  proxy-net:
    external: true
