FROM python:3.10-slim # 系统依赖:ffmpeg 用于音频编解码/重采样,libsndfile 给 soundfile 用 RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ libsndfile1 \ git \ curl \ build-essential \ && rm -rf /var/lib/apt/lists/* # deepfilternet 依赖 deepfilterlib,PyPI 上没有预编译 wheel, # 必须现场编译 Rust 扩展,所以这里装 Rust 工具链 RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable ENV PATH="/root/.cargo/bin:${PATH}" WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # 预下载 DeepFilterNet 模型权重,避免每次冷启动都下载 RUN python -c "from df.enhance import init_df; init_df()" || true COPY . . # HF Space 默认监听 7860 ENV GRADIO_SERVER_NAME=0.0.0.0 ENV GRADIO_SERVER_PORT=7860 ENV MODEL_DIR=/app/models RUN mkdir -p /app/models /app/tmp EXPOSE 7860 CMD ["python", "app.py"]