Kaynağa Gözat

feat: dockerfile替换源同时替换http为https

z 4 gün önce
ebeveyn
işleme
3ac68e25f8
1 değiştirilmiş dosya ile 6 ekleme ve 3 silme
  1. 6 3
      Dockerfile

+ 6 - 3
Dockerfile

@@ -1,8 +1,10 @@
 # Stage 1: Install dependencies (isolated layout, same as local dev)
 FROM node:22-bookworm AS deps
 
-# 使用阿里云镜像源
-RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources
+# 使用阿里云镜像源。
+# 注意: Kaniko 构建时挂了 HTTP/HTTPS 代理, 该代理只放行 HTTPS(CONNECT 隧道),
+# 拒绝转发明文 HTTP(会返回 403)。所以 apt 源必须用 https://, 不能用 http://。
+RUN sed -i 's|http://deb.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources
 
 RUN corepack enable && corepack prepare pnpm@10.24.0 --activate
 
@@ -35,7 +37,8 @@ RUN pnpm build
 # Stage 3: Runtime — fresh prod install with hoisted layout
 FROM node:22-bookworm-slim AS runtime
 
-RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources
+# 同上: apt 源用 https, 走代理 CONNECT 隧道, 避免明文 HTTP 被 403。
+RUN sed -i 's|http://deb.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources
 
 RUN corepack enable && corepack prepare pnpm@10.24.0 --activate