fix(Dockerfile): 移除不安全套件憑證忽略並釘選 Alpine
This commit is contained in:
+4
-7
@@ -6,18 +6,15 @@
|
||||
# 更新日期:2026/06/26 11:34:46
|
||||
# =============================================================================
|
||||
|
||||
# 指定基底映像為 Alpine Linux 最新版;Alpine 體積小,可縮小最終映像大小並加快拉取速度。
|
||||
# 需人工確認:使用 latest tag 會在不同時間建置出不同基底版本,可能影響可重現性,
|
||||
# 建議釘選明確版本(例如 alpine:3.20)以確保建置一致。
|
||||
FROM alpine:latest
|
||||
# 指定支援中的 Alpine Linux 固定版本;Alpine 體積小,可縮小最終映像大小並加快拉取速度。
|
||||
# 釘選明確版本可避免 latest tag 隨時間變動,提升建置可重現性。
|
||||
FROM alpine:3.24.1
|
||||
|
||||
# 安裝必要的工具
|
||||
# 安裝執行 code review 所需的工具:bash(執行 entrypoint 腳本)、git(前置遠端驗證/取得 diff)、
|
||||
# nodejs 與 npm(執行 app 內的 Node.js 程式)。
|
||||
# --no-cache:不保留 apk 套件索引快取,避免殘留在映像層中以減少映像大小。
|
||||
# 需人工確認:--no-check-certificate 會略過套件來源的憑證驗證,存在中間人攻擊風險,
|
||||
# 僅在內網或憑證受限環境下使用;正式環境建議移除以維持安全性。
|
||||
RUN apk add --no-cache --no-check-certificate bash git nodejs npm
|
||||
RUN apk add --no-cache bash git nodejs npm
|
||||
|
||||
# 將專案的 app/ 目錄複製到映像內的 /app;包含 Node.js 程式碼與 package.json 等相依宣告。
|
||||
COPY ./app /app
|
||||
|
||||
Reference in New Issue
Block a user