# ─────────────────────────────────────────────────────────────────────────────
#  TTS Voice Creator - Clone and Design 2 — Portainer Stack
#
#  IMPORTANT: build the image on the host before deploying / updating this stack:
#
#    cd /home/sparky/Docker/tts-voice-creator-clone-and-design-2
#    docker build -t tts-voice-creator-clone-and-design-2:latest .
#
#  Then paste this file into Portainer → Stacks → Add stack → Web editor
#  (or update the existing stack).
#
#  This reconstructs the current stack from the running container plus the
#  current app code. The older Portainer cache used 7890:7860, but this version
#  listens on container port 7890.
#
#  After any Python code change (core/ or routes/) you must recreate/redeploy
#  this stack or rebuild the image. Static files are bind-mounted.
# ─────────────────────────────────────────────────────────────────────────────

services:
  tts-voice-creator-clone-and-design-2:
    image: tts-voice-creator-clone-and-design-2:latest
    container_name: tts-voice-creator-clone-and-design-2
    restart: unless-stopped

    ports:
      - "7890:7890"

    group_add:
      - "988"

    volumes:
      - /home/sparky/Media/_Sounds/TTS_Voices:/voices:rw
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/config:/home/app/.config/tts-voice-creator:rw
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/logs:/logs:rw
      - /home/sparky/Docker/tts-dgx-spark-faster-qwen3-tts/config:/tts-config:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # ── Hot-reload mounts (changes apply on container recreate, not restart) ──
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/server.py:/app/server.py:ro
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/core:/app/core:ro
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/routes:/app/routes:ro
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/static:/app/static:ro
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/VERSION:/app/VERSION:ro
      - /home/sparky/Docker/tts-voice-creator-clone-and-design-2/CHANGELOG.md:/app/CHANGELOG.md:ro

    environment:
      - PYTHONUNBUFFERED=1
      - VOICES_DIR=/voices
      - OUTPUT_DIR=/voices/active_voices
      - TTS_STREAM_URL=http://host.docker.internal:8023
      - TTS_CONTAINER_NAME=tts-faster-qwen3-tts-voiceclone
      - TTS_CONTAINER_NAMES=tts-faster-qwen3-tts-voiceclone,tts-faster-qwen3-tts-streaming
      - VOICE_DESIGN_MODEL=Qwen3-TTS-12Hz-1.7B-VoiceDesign

    extra_hosts:
      - "host.docker.internal:host-gateway"

    networks:
      - dgx_net

networks:
  dgx_net:
    external: true
