基镜像构建挂了——日志显示 pip 在装 requirements.txt 阶段退出码 1, 罪魁是阿里云 pypi 镜像对 mcp==1.22.0 的元数据文件 404。 装包那行加 --extra-index-url https://pypi.org/simple, 主源没货时自动去官方源捞。
33 lines
1.2 KiB
Plaintext
33 lines
1.2 KiB
Plaintext
# Dockerfile-server-base
|
|
# 基础镜像,包含系统依赖和Python包
|
|
FROM python:3.10-slim
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends libopus0 ffmpeg locales && \
|
|
sed -i '/zh_CN.UTF-8/s/^# //g' /etc/locale.gen && \
|
|
locale-gen && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# 配置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
|
|
|
|
# 设置环境变量以确保正确的字符编码
|
|
ENV LANG=zh_CN.UTF-8 \
|
|
LC_ALL=zh_CN.UTF-8 \
|
|
LANGUAGE=zh_CN:zh \
|
|
PYTHONIOENCODING=utf-8
|
|
|
|
WORKDIR /opt/xiaozhi-esp32-server
|
|
|
|
# 复制requirements.txt
|
|
COPY main/xiaozhi-server/requirements.txt .
|
|
|
|
# 安装Python依赖
|
|
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
|
# 阿里云 PyPI 镜像偶有元数据 404,加官方源作 fallback
|
|
pip install --no-cache-dir -r requirements.txt --default-timeout=120 --retries 5 --extra-index-url https://pypi.org/simple |