Files
esh-pfi-infrastructure/stacks/index-tts/Dockerfile
T
vh 6fd35bfe37 stacks/index-tts: install git-lfs in image so examples come down real
The IndexTTS-2 repo stores examples/emo_*.wav and examples/voice_*.wav
as Git LFS objects. v1 of our image cloned the repo without an LFS
pull, leaving those paths as ~130-byte pointer text files — unusable
for `docker cp` into /worktank/index-tts/{voices,emotions}/ as starter
references. (Caught when an emotion_voice="hate" call returned audio
that was actually the pointer text round-tripped through file IO.)

v2 adds git-lfs to the apt list, calls `git lfs install --system`
once, and `git lfs pull` after the checkout. Adds ~1-2 MB to the
image (the examples are small audio clips). INDEX_TTS_TAG bumped to
v2 to force a clean rebuild.
2026-04-25 14:22:07 -07:00

67 lines
2.5 KiB
Docker

# syntax=docker/dockerfile:1.6
#
# IndexTTS-2 served behind our own thin FastAPI wrapper (~150 lines in
# app.py). Upstream ships only a Gradio webui; the existing csllpr
# FastAPI fork is for v1 and dormant. We own the wrapper end-to-end.
ARG CUDA_BASE=nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
FROM ${CUDA_BASE}
ENV DEBIAN_FRONTEND=noninteractive \
PIP_ROOT_USER_ACTION=ignore \
PYTHONUNBUFFERED=1 \
PATH="/opt/venv/bin:${PATH}"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3.10 python3.10-venv python3-pip \
git git-lfs ffmpeg libsndfile1 \
ca-certificates wget \
&& rm -rf /var/lib/apt/lists/* \
&& python3.10 -m venv /opt/venv \
&& git lfs install --system
# Pinned IndexTTS-2 SHA — bump in stack .env (INDEX_TTS_SHA build arg)
# when you want upstream updates.
#
# `git lfs pull` after the checkout fetches examples/emo_*.wav and the
# example/voice_*.wav reference clips that are stored as LFS objects.
# Without it, the .wav files come down as ~130-byte LFS pointer text
# files, and `docker cp`-ing them out as starter material for
# /worktank/index-tts/{voices,emotions} produces unusable garbage.
ARG INDEX_TTS_SHA=830f6f8f94a51fea23ab1d639027a86200075a4e
RUN git clone https://github.com/index-tts/index-tts.git /opt/index-tts \
&& cd /opt/index-tts \
&& git checkout ${INDEX_TTS_SHA} \
&& git lfs pull
# CUDA 12.8 torch wheels (per IndexTTS pyproject.toml's tool.uv.index
# pin — same versions, same source).
RUN pip install --no-cache-dir \
torch==2.8.0 torchaudio==2.8.0 \
--index-url https://download.pytorch.org/whl/cu128
# IndexTTS package + its long pinned-deps tail (numpy 1.26.2, transformers
# 4.52.1, sentencepiece, librosa, descript-audiotools, jieba/g2p-en/cn2an,
# WeTextProcessing, modelscope, accelerate, safetensors, etc.).
# BigVGAN is vendored under indextts/ so it resolves without a pip dep.
RUN cd /opt/index-tts && pip install --no-cache-dir -e .
# Wrapper deps (FastAPI stack + soundfile for in-memory WAV encoding).
RUN pip install --no-cache-dir \
fastapi 'uvicorn[standard]' python-multipart soundfile
WORKDIR /app
COPY app.py /app/app.py
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 8000
# wget is in the base image (added above); curl is not.
HEALTHCHECK --interval=30s --timeout=10s --start-period=600s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1:8000/healthz || exit 1
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]