indextts2-api / Dockerfile
talfaf's picture
fix: pre-download aux models only (avoid build OOM)
755640e verified
Raw History Blame Contribute Delete
1.07 kB
FROM python:3.10-slim
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/data/cache \
MODEL_DIR=/data/indextts2
# ffmpeg: 音频处理; git: 安装 indextts 源码包
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg git curl ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt ./
RUN pip install --upgrade pip && pip install -r requirements.txt
# 构建期把模型权重烘进镜像(public repo, 无需 token), 避免每次冷启动下载 6GB
RUN python -c "from huggingface_hub import snapshot_download; \
snapshot_download(repo_id='IndexTeam/IndexTTS-2', local_dir='/data/indextts2')"
# 预热: 构建期预下载辅助模型(w2v-bert/MaskGCT/CAMPPlus/BigVGAN)到 hf_cache,
# 不加载模型(避免构建容器 OOM), 冷启动从 ~4min 降到 ~1min
RUN python -c "from indextts.utils.model_download import ensure_models_available; \
ensure_models_available('/data/indextts2')"
COPY app.py ./
ENV PORT=7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]