Files
ai-code-review/Dockerfile
T

38 lines
2.2 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# =============================================================================
# 用途:建置「AI 程式碼審查」Docker action 映像檔。
# 以 Alpine Linux 為基底,安裝 bash / git / Node.js / npm 等執行環境,
# 將 app/ 程式碼與相依套件打包進映像,並透過 entrypoint.sh 作為容器進入點,
# 供 CIGitea Actions)以 Docker action 形式執行 AI code review 流程。
# 更新日期:2026/06/26 11:34:46
# =============================================================================
# 指定基底映像為 Alpine Linux 最新版;Alpine 體積小,可縮小最終映像大小並加快拉取速度。
# 需人工確認:使用 latest tag 會在不同時間建置出不同基底版本,可能影響可重現性,
# 建議釘選明確版本(例如 alpine:3.20)以確保建置一致。
FROM alpine:latest
# 安裝必要的工具
# 安裝執行 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
# 將專案的 app/ 目錄複製到映像內的 /app;包含 Node.js 程式碼與 package.json 等相依宣告。
COPY ./app /app
# 進入 /app 安裝 npm 相依套件,使 Node.js 程式可在容器內正常執行。
# 副作用:會在 /app/node_modules 產生套件檔案,並依 package-lock.json(若存在)解析版本。
RUN cd /app && npm install
# 將容器進入點腳本 entrypoint.sh 複製到映像根目錄 /entrypoint.sh。
COPY entrypoint.sh /entrypoint.sh
# 賦予 entrypoint.sh 可執行權限,確保容器啟動時能直接執行該腳本。
RUN chmod +x /entrypoint.sh
# 設定容器進入點為 /entrypoint.shexec 形式,不經過 shell 解析);
# 容器啟動時即執行此腳本,作為 Docker action 的實際入口。
ENTRYPOINT ["/entrypoint.sh"]