# Dia2 (Nari Labs' dialogue-focused TTS) served via devnen/Dia-TTS-Server.
#
# Dialogue scenes none of the other bench TTS own cleanly: multi-speaker
# turn-taking in one pass with inline [S1]/[S2] tags + nonverbals
# (laughs)/(coughs)/(sighs). OpenAI-compat POST /v1/audio/speech.
#
# This stack runs TWO fixed-model instances from the dia2-capable image
# (local/dia:v2 — built in two stages: the upstream devnen wrapper image
# local/dia:v1, then dia2-image/Dockerfile layers in the dia2 package +
# its missing runtime deps; see README). The wrapper serves whatever model
# is loaded and IGNORES per-request model selection, so the only way to
# offer multiple Dia2 models to asset-engine as real choices is one fixed
# instance per model — which is exactly this:
#   * dia2-2b — Dia2 2B, highest quality   (:8200, the primary dia port)
#   * dia2-1b — Dia2 1B, streaming/faster   (:8202)
# Each pins ONE model via its mounted config.yaml. Legacy Dia 1.6B retired
# (operator decision 2026-05-31).
#
# All tunables live in .env — edit that, not this file.

services:
  dia2-2b:
    image: local/dia:${DIA_TAG}
    container_name: dia2-2b
    restart: unless-stopped
    runtime: nvidia
    ports:
      - "${DIA_BIND:-0.0.0.0}:${DIA2_2B_PORT}:8003"
    environment:
      - NVIDIA_VISIBLE_DEVICES=${DIA2_2B_GPU:-0}
      - NVIDIA_DRIVER_CAPABILITIES=compute,utility
      - HF_HUB_ENABLE_HF_TRANSFER=1
      - HF_HOME=/app/hf_cache
    volumes:
      - ${DIA_REFERENCE_DIR}:/app/reference_audio
      - ${DIA_CACHE_DIR}:/app/hf_cache
      # Pins model.repo_id=nari-labs/Dia2-2B (highest quality).
      - ${DIA2_2B_CONFIG}:/app/config.yaml
    healthcheck:
      test: ["CMD-SHELL", "python3 -c \"import urllib.request,sys; urllib.request.urlopen('http://127.0.0.1:8003/health', timeout=5); sys.exit(0)\""]
      interval: 30s
      timeout: 10s
      retries: 3
      # First boot pulls the Dia2-2B checkpoint — generous deadline.
      start_period: 600s
    labels:
      - homepage.group=AI Systems
      - homepage.name=Dia2 2B (HQ)
      - homepage.icon=mdi-account-voice
      - homepage.description=Dialogue TTS — Dia2 2B, highest quality (irv-ml1)
      - homepage.href=http://10.100.79.3:${DIA2_2B_PORT}

  dia2-1b:
    image: local/dia:${DIA_TAG}
    container_name: dia2-1b
    restart: unless-stopped
    runtime: nvidia
    ports:
      - "${DIA_BIND:-0.0.0.0}:${DIA2_1B_PORT}:8003"
    environment:
      - NVIDIA_VISIBLE_DEVICES=${DIA2_1B_GPU:-0}
      - NVIDIA_DRIVER_CAPABILITIES=compute,utility
      - HF_HUB_ENABLE_HF_TRANSFER=1
      - HF_HOME=/app/hf_cache
    volumes:
      - ${DIA_REFERENCE_DIR}:/app/reference_audio
      - ${DIA_CACHE_DIR}:/app/hf_cache
      # Pins model.repo_id=nari-labs/Dia2-1B (streaming, lower latency).
      - ${DIA2_1B_CONFIG}:/app/config.yaml
    healthcheck:
      test: ["CMD-SHELL", "python3 -c \"import urllib.request,sys; urllib.request.urlopen('http://127.0.0.1:8003/health', timeout=5); sys.exit(0)\""]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 600s
    labels:
      - homepage.group=AI Systems
      - homepage.name=Dia2 1B (Streaming)
      - homepage.icon=mdi-account-voice
      - homepage.description=Dialogue TTS — Dia2 1B, streaming/faster (irv-ml1)
      - homepage.href=http://10.100.79.3:${DIA2_1B_PORT}
