LLM_demo_docker / Dockerfile
chenjianfei
2
8b7d527
# 第一阶段:强制安装完整依赖链
FROM python:3.9-slim AS builder
# 1. 更新CA证书并安装系统工具
# RUN apt-get update && apt-get install -y \
# ca-certificates \
# && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
ca-certificates \
libcurl4-openssl-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# 2. 安装核心依赖(包含git)
RUN apt-get update && apt-get install -y \
ffmpeg libsndfile1 git \
&& rm -rf /var/lib/apt/lists/*
# 3. 构建OpenVoice(此时git已可用)
WORKDIR /app
COPY OpenVoice/ ./OpenVoice
RUN pip install numpy==1.22.0 && \
pip install -e ./OpenVoice
# 第二阶段:继承所有依赖
FROM python:3.9-slim
COPY --from=builder /usr/bin/git /usr/bin/git
COPY --from=builder /app/OpenVoice /app/OpenVoice
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
# 安装主程序依赖
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 7860
CMD ["python", "app.py"]