From 091ee05e58b3f28ba03926c7b9502fb994d4c60c Mon Sep 17 00:00:00 2001 From: aszerW Date: Thu, 26 Mar 2026 21:21:59 +0800 Subject: [PATCH] =?UTF-8?q?chore(docker):=20=E4=BC=98=E5=8C=96Dockerfile?= =?UTF-8?q?=5Fbase=E9=95=9C=E5=83=8F=E6=9E=84=E5=BB=BA=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更换阿里云镜像源提升apt-get安装速度 - 新增openssh-client和autossh系统依赖 - 所有apt-get操作后统一清理缓存 - Playwright依赖安装使用阿里云源镜像 - 安装中文字体时允许失败不影响构建 - 保持时区配置为Asia/Shanghai - 安装Playwright chromium浏览器版本一致 --- Dockerfile_base | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile_base b/Dockerfile_base index c82bb3d..1bc45b8 100644 --- a/Dockerfile_base +++ b/Dockerfile_base @@ -3,13 +3,16 @@ FROM python:3.12-slim # 设置工作目录 WORKDIR /app -# 安装系统依赖 -RUN apt-get update && apt-get install -y \ +# 更换阿里云镜像源并安装系统依赖 +RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \ + apt-get update && apt-get install -y \ wget \ gnupg \ + openssh-client \ + autossh \ && rm -rf /var/lib/apt/lists/* -# 安装Playwright的依赖 +# 安装Playwright的依赖(使用阿里云源) RUN apt-get update && apt-get install -y \ libnss3 \ libnspr4 \ @@ -27,7 +30,7 @@ RUN apt-get update && apt-get install -y \ libasound2 \ libpango-1.0-0 \ libpangocairo-1.0-0 \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* # 配置pip源 RUN mkdir -p /root/.pip && \ @@ -42,7 +45,7 @@ RUN apt-get update && \ apt-get install -y --no-install-recommends tzdata && \ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ dpkg-reconfigure -f noninteractive tzdata && \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/* RUN pip install uv \ && rm -rf /root/.cache/pip @@ -62,14 +65,14 @@ RUN uv pip install --system -r requirements.txt RUN apt-get update && apt-get install -y \ xvfb \ libopengl0 \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* -# 安装中文字体 +# 安装中文字体(使用阿里云源,允许失败) RUN apt-get update && apt-get install -y \ fonts-noto-cjk \ fonts-wqy-zenhei \ fonts-wqy-microhei \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* || echo "字体安装失败,继续构建" # 安装Playwright浏览器 RUN playwright install chromium