使用华为镜像加速构建包下载过程

This commit is contained in:
JoeyZhou 2025-03-28 11:50:38 +08:00
parent 97b777f1b2
commit a1fd7aed59
2 changed files with 10 additions and 6 deletions

View file

@ -5,16 +5,17 @@ WORKDIR /app
COPY main/xiaozhi-server/requirements.txt .
# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt
# 安装Python依赖,使用阿里云镜像源加速
RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple -r requirements.txt
# 第二阶段:生产镜像
FROM python:3.10-slim
WORKDIR /opt/xiaozhi-esp32-server
# 安装系统依赖
RUN apt-get update && \
# 安装系统依赖,使用华为云镜像源加速
RUN sed -i 's|http://deb.debian.org/debian|http://mirrors.huaweicloud.com/debian|g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && \
apt-get install -y --no-install-recommends libopus0 ffmpeg && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

View file

@ -16,8 +16,11 @@ RUN mvn clean package -Dmaven.test.skip=true
# 第三阶段:构建最终镜像
FROM eclipse-temurin:21-jdk-jammy
# 安装Nginx并清理缓存
RUN apt-get update && \
# 安装Nginx并清理缓存,使用华为云镜像源
RUN sed -i "s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list && \
sed -i "s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list && \
echo "当前的 APT 源配置:" && cat /etc/apt/sources.list && \
apt-get update && \
apt-get install -y nginx && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*