# ComfyUI + TRELLIS.2 auf Turing-GPUs (SM 7.5)
# Getestet mit Quadro RTX 6000 (24 GB VRAM)
#
# Image: cu128-megapak-pt29 = CUDA 12.8 + PyTorch 2.9.1 + GCC 11
# Grund: Torch291-Wheels für Trellis2 (nvdiffrast, cumesh etc.)
#        passen exakt zu dieser PyTorch-Version.
#
# Verwendung:
#   podman-compose up -d
#   podman-compose logs -f comfyui
#
# Erster Start dauert länger (Downloads von ComfyUI, Custom Nodes, Dependencies).
# Die SM 7.5 CUDA-Overrides müssen vorher gebaut werden — siehe pre-start.sh.

services:
  comfyui:
    image: docker.io/yanwk/comfyui-boot:cu128-megapak-pt29
    container_name: comfyui
    hostname: comfyui

    # --- GPU-Zugriff (Podman CDI) ---
    # Für Docker: runtime: nvidia + NVIDIA_VISIBLE_DEVICES=all
    devices:
      - nvidia.com/gpu=all

    # --- Ports ---
    ports:
      - "8188:8188"

    # --- Volumes ---
    volumes:
      # Hauptverzeichnis (ComfyUI-Installation, venv, configs)
      - ./storage:/root
      # Modelle separat — containerübergreifend nutzbar
      - ./storage-models/models:/root/ComfyUI/models
      - ./storage-models/hf-hub:/root/.cache/huggingface/hub
      - ./storage-models/torch-hub:/root/.cache/torch/hub
      # User-Daten
      - ./storage-user/input:/root/ComfyUI/input
      - ./storage-user/output:/root/ComfyUI/output
      - ./storage-user/workflows:/root/ComfyUI/user/default/workflows
      # SM 7.5 CUDA-Kernel-Overrides (read-only)
      - ./storage/sm75-overrides:/run/sm75-overrides:ro

    # --- Umgebungsvariablen ---
    environment:
      CLI_ARGS: "--listen 0.0.0.0 --preview-method auto"
      # Hugging Face Token für Download der Modelle
      HF_TOKEN: "${HF_TOKEN}"
      # flex_gemm statt spconv — bessere Mesh-Qualität
      SPARSE_CONV_BACKEND: "flex_gemm"

    # --- Container-Verhalten ---
    restart: unless-stopped
    stdin_open: true
    tty: true
    shm_size: "32g"
