File size: 1,072 Bytes
e15e1c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755640e
 
 
 
6a2f21a
e15e1c1
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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"]