浏览代码

📦 build(docker): optimize Dockerfile configuration and dependency installation

- add Debian official GPG keys to fix package verification issues
- install ca-certificates to ensure proper SSL certificate handling
- split apt commands into logical sections for better maintainability
- add gnupg package required for GPG key management
- remove unnecessary blank line for cleaner Dockerfile structure
yourname 1 月之前
父节点
当前提交
3e7ce6d3e3
共有 1 个文件被更改,包括 15 次插入9 次删除
  1. 15 9
      Dockerfile

+ 15 - 9
Dockerfile

@@ -1,15 +1,23 @@
 # 使用指定基础镜像
 FROM docker.1ms.run/node:20.19.4-bookworm
 
-# 设置软件源为清华大学镜像源
-# 替换 Debian 源为清华镜像(覆盖整个 sources.list 文件)
+# 设置软件源为清华大学镜像源,并先安装必要的工具
 RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
     echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
     echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
     echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list
 
-RUN apt update  --fix-missing && \
-    apt install -y curl wget
+# 先更新并安装curl(不验证签名),然后添加GPG密钥
+RUN apt update --allow-unauthenticated --fix-missing && \
+    apt install -y curl wget gnupg
+
+# 添加Debian官方GPG密钥
+RUN wget -qO - https://ftp-master.debian.org/keys/archive-key-$(lsb_release -sr).asc | apt-key add - && \
+    wget -qO - https://ftp-master.debian.org/keys/archive-key-$(lsb_release -sr)-security.asc | apt-key add -
+
+# 现在可以正常更新和安装其他软件
+RUN apt update --fix-missing && \
+    apt install -y ca-certificates
 
 # 安装 pnpm
 RUN npm install -g pnpm
@@ -22,10 +30,9 @@ RUN pnpm config set @jsr:registry https://npm.jsr.io
 RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
     echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list
 
-# 更新包列表并安装PostgreSQL 17客户端工具及其他常用工具(已添加jq)
-RUN apt install -y \
-    # PostgreSQL 17客户端工具
-    postgresql-client-17
+# 更新包列表并安装PostgreSQL 17客户端工具
+RUN apt update && \
+    apt install -y postgresql-client-17
 
 # 确认版本
 RUN pg_dump --version
@@ -49,7 +56,6 @@ RUN pnpm install --frozen-lockfile
 # 复制项目文件
 COPY . .
 
-
 # 构建 web 应用
 RUN cd web && pnpm run build