# ============================================================================= # 用途:建置「AI 程式碼審查」Docker action 映像檔。 # 以 Alpine Linux 為基底,安裝 bash / git / Node.js / npm 等執行環境, # 將 app/ 程式碼與相依套件打包進映像,並透過 entrypoint.sh 作為容器進入點, # 供 CI(Gitea Actions)以 Docker action 形式執行 AI code review 流程。 # 更新日期:2026/06/26 11:34:46 # ============================================================================= # 指定支援中的 Alpine Linux 固定版本;Alpine 體積小,可縮小最終映像大小並加快拉取速度。 # 釘選明確版本可避免 latest tag 隨時間變動,提升建置可重現性。 FROM alpine:3.24.1 # 安裝必要的工具 # 安裝執行 code review 所需的工具:bash(執行 entrypoint 腳本)、git(前置遠端驗證/取得 diff)、 # nodejs 與 npm(執行 app 內的 Node.js 程式)。 # --no-cache:不保留 apk 套件索引快取,避免殘留在映像層中以減少映像大小。 RUN apk add --no-cache 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.sh(exec 形式,不經過 shell 解析); # 容器啟動時即執行此腳本,作為 Docker action 的實際入口。 ENTRYPOINT ["/entrypoint.sh"]