62 lines
2.4 KiB
Plaintext
62 lines
2.4 KiB
Plaintext
# 第一阶段:构建Python依赖
|
||
FROM condaforge/mambaforge:latest AS builder
|
||
|
||
|
||
WORKDIR /app
|
||
|
||
# 使用mamba提供的Python与工具(安装Python 3.10与git)
|
||
RUN mamba install -y -c conda-forge python=3.12.4 pip git && \
|
||
mamba clean -afy
|
||
|
||
# 配置pip使用国内镜像源(阿里云)并设置超时和重试
|
||
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
|
||
pip config set global.trusted-host mirrors.aliyun.com && \
|
||
pip config set global.timeout 120 && \
|
||
pip config set install.retries 5
|
||
|
||
COPY main/xiaozhi-server/requirements.txt .
|
||
|
||
# 安装Python依赖,使用并行下载
|
||
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
||
pip install --no-cache-dir -r requirements.txt --default-timeout=120 --retries 5
|
||
|
||
# lang-agent安装(不可跳过):匿名克隆失败则尝试凭据克隆,仍失败直接终止构建;安装为开发模式
|
||
RUN git clone https://gitea.tangledup-ai.com//Quant-Speed-AI/lang-agent.git /opt/lang-agent
|
||
# RUN git clone http://6.6.6.86:3321/Quant-Speed-AI/lang-agent.git /opt/lang-agent
|
||
|
||
RUN python -m pip install -e /opt/lang-agent
|
||
|
||
# 第二阶段:生产镜像
|
||
FROM condaforge/mambaforge:latest
|
||
|
||
WORKDIR /opt/xiaozhi-esp32-server
|
||
|
||
# 使用mamba安装运行期系统依赖与Python 3.12.4
|
||
RUN mamba install -y -c conda-forge python=3.12.4 pip libopus ffmpeg curl zip mamba unzip vim && \
|
||
mamba clean -afy
|
||
|
||
# 确保PATH包含conda bin
|
||
ENV PATH="/opt/conda/bin:${PATH}"
|
||
|
||
# 从构建阶段复制Python包与脚本(基于mamba Python路径)
|
||
COPY --from=builder /opt/conda/lib/python3.12/site-packages /opt/conda/lib/python3.12/site-packages
|
||
COPY --from=builder /opt/conda/bin/mcp-proxy /opt/conda/bin/mcp-proxy
|
||
|
||
# 复制应用代码
|
||
COPY main/xiaozhi-server .
|
||
|
||
# 复制lang-agent源码到最终镜像,确保可开发与egg-link有效
|
||
COPY --from=builder /opt/lang-agent /opt/lang-agent
|
||
RUN curl -o /opt/lang-agent/.env http://6.6.6.86:8888/download/resources/.env
|
||
RUN curl -o /opt/lang-agent/asset.zip http://6.6.6.86:8888/download/resources/assets.zip
|
||
RUN unzip /opt/lang-agent/asset.zip -d /opt/lang-agent
|
||
RUN rm /opt/lang-agent/asset.zip
|
||
|
||
# 下载SenseVoiceSmall模型文件(删除可能存在的目录或旧文件后下载)
|
||
RUN rm -rf models/SenseVoiceSmall/model.pt
|
||
RUN mkdir -p models/SenseVoiceSmall
|
||
RUN curl -L -o models/SenseVoiceSmall/model.pt https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt
|
||
|
||
|
||
# 启动应用
|
||
CMD ["python", "app.py"] |