From ab95b1e4987197c16307a4e9a8ccc06b7cad900b Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Wed, 11 Mar 2026 16:05:04 +0800 Subject: [PATCH] =?UTF-8?q?bug=20fix=E3=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile | 61 +++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 3e50836..a64ee6f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -11,26 +11,47 @@ ENV PYTHONUNBUFFERED=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_DEFAULT_TIMEOUT=120 -# 替换为阿里云 Debian 镜像源(国内加速) -RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \ - sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources - -# 安装系统依赖(含 WeasyPrint 渲染库 + CJK/等宽系统字体) -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - default-libmysqlclient-dev \ - pkg-config \ - libpango-1.0-0 \ - libpangoft2-1.0-0 \ - libpangocairo-1.0-0 \ - libgdk-pixbuf-2.0-0 \ - libcairo2 \ - libffi-dev \ - shared-mime-info \ - fontconfig \ - fonts-dejavu-core \ - fonts-wqy-microhei \ - && rm -rf /var/lib/apt/lists/* +# 优先尝试阿里云 Debian 镜像源,失败时自动回退官方源 +RUN set -eux; \ + cp /etc/apt/sources.list.d/debian.sources /tmp/debian.sources.bak; \ + sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources; \ + sed -i 's|http://security.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources; \ + if ! apt-get update; then \ + cp /tmp/debian.sources.bak /etc/apt/sources.list.d/debian.sources; \ + apt-get update; \ + fi; \ + if ! apt-get install -y --no-install-recommends \ + build-essential \ + default-libmysqlclient-dev \ + pkg-config \ + libpango-1.0-0 \ + libpangoft2-1.0-0 \ + libpangocairo-1.0-0 \ + libgdk-pixbuf-2.0-0 \ + libcairo2 \ + libffi-dev \ + shared-mime-info \ + fontconfig \ + fonts-dejavu-core \ + fonts-wqy-microhei; then \ + cp /tmp/debian.sources.bak /etc/apt/sources.list.d/debian.sources; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + build-essential \ + default-libmysqlclient-dev \ + pkg-config \ + libpango-1.0-0 \ + libpangoft2-1.0-0 \ + libpangocairo-1.0-0 \ + libgdk-pixbuf-2.0-0 \ + libcairo2 \ + libffi-dev \ + shared-mime-info \ + fontconfig \ + fonts-dejavu-core \ + fonts-wqy-microhei; \ + fi; \ + rm -rf /var/lib/apt/lists/* # 复制依赖文件 COPY requirements.txt .