FROM python:3.10-slim # 1. 系统依赖 RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ git \ build-essential \ && rm -rf /var/lib/apt/lists/* RUN pip install --no-cache-dir --upgrade pip # 2. PyTorch CPU 依赖 RUN pip install --no-cache-dir \ torch \ torchaudio \ --extra-index-url https://download.pytorch.org/whl/cpu # 3. Python 库 RUN pip install --no-cache-dir \ fastapi \ uvicorn \ python-multipart \ funasr \ modelscope \ soundfile \ librosa \ numpy \ scipy \ av \ huggingface_hub # 4. 用户与环境 RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # 5. 【修正后的官方 HF 仓库名】: # SenseVoiceSmall: FunAudioLLM/SenseVoiceSmall # emotion2vec+: emotion2vec/emotion2vec_plus_seed RUN python3 -c "from huggingface_hub import snapshot_download; \ snapshot_download('FunAudioLLM/SenseVoiceSmall', local_dir='/home/user/app/models/SenseVoiceSmall'); \ snapshot_download('emotion2vec/emotion2vec_plus_seed', local_dir='/home/user/app/models/emotion2vec_plus_seed')" # 6. 复制代码 COPY --chown=user . . EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]