Files
JefferyandClaude Fable 5 597fa4119b
docker-actions/template: CI / BUILD (pull_request) Successful in 5s
feat: 實作 Clean Old Release action
- 依建立時間將 release 分為正式版與 beta 版(tag 含 beta),各自保留最新指定筆數(keep_count 預設 5、keep_count_beta 預設 10),其餘舊 release 連同對應 git tag 一併刪除
- Node.js 主程式置於 src/(index.js 主流程、logger.js 統一訊息格式 [yyyy/MM/dd HH:mm:ss][階段][等級]: 訊息)
- 多階段建置 dockerfile(NODE_VERSION=latest / NODE_RUNTIME=slim),entrypoint.sh 輸出啟動訊息後 exec 主程式
- 補齊全部 JSDoc 與指令檔逐行註解,重建 readme.md
- 移除範本的 .gitea/scoped_workflows/ci.yaml

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 08:38:21 +08:00

42 lines
1.8 KiB
Docker
Raw Permalink 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.
# syntax=docker/dockerfile:1
# ============================================================================
# 用途:建置 Gitea docker action「Clean Old Release」的容器映像;採多階段建置
# build 階段整理產物、runtime 階段改用 node:slim 縮小映像),
# action 執行時由 /action/entrypoint.sh 啟動 Node.js 主程式清理舊 Release。
# 更新時間:2026/07/16 14:15:41
# ============================================================================
# 1. 參數處理:build 階段 Node 版本以 ARG 注入,預設 latest,可於建置時覆寫
ARG NODE_VERSION=latest
# runtime 階段基底標籤,預設 slim 以縮小最終映像體積
ARG NODE_RUNTIME=slim
# ---- build 階段:整理產物 ----
# 以 node:${NODE_VERSION} 作為 build 階段基底並命名為 build,供後續階段引用
FROM node:${NODE_VERSION} AS build
# 設定工作目錄為 /action,後續 COPY/RUN 皆以此為基準路徑
WORKDIR /action
# 2. 複製檔案:帶入 Node.js 主程式(僅用 Node 內建模組,無相依套件需安裝)
COPY src/ /action/src/
# 帶入容器入口腳本,負責啟動 node 主程式
COPY entrypoint.sh /action/entrypoint.sh
# 3. 執行程序:賦予 entrypoint 執行權限,否則 runtime 階段無法作為 ENTRYPOINT 執行
RUN chmod +x /action/entrypoint.sh
# 4. 縮小映像檔:runtime 改用 node:${NODE_RUNTIME}slim)基底,只帶必要產物
FROM node:${NODE_RUNTIME} AS runtime
# 於 runtime 階段同樣以 /action 為工作目錄,維持與 build 階段一致的路徑
WORKDIR /action
# 從 build 階段複製整理好的產物(src/ 與已具執行權限的 entrypoint.sh
COPY --from=build /action /action
# 5. 設定入口:容器啟動時以 entrypoint.sh 執行 node 主程式
ENTRYPOINT ["/action/entrypoint.sh"]