Files
release-cleanup/Dockerfile
T

54 lines
3.0 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
# =============================================================================
# 此 Dockerfile 的用途:
# 建置 Release Cleanup docker container action 的映像。
# 以 node alpine 為基底,複製 app/ 主程式與 entrypoint.sh,設定入口。
#
# 更新日期(台灣時區 Asia/Taipei):2026/07/01 09:14:10
# =============================================================================
# -----------------------------------------------------------------------------
# 1. 參數處理:node base image tag 以 ARG 注入
# - 預設 lts-alpine;建置時可用 --build-arg NODE_VERSION=... 覆寫
# - 主程式以原生 fetch 呼叫 Gitea API(需 Node 18+),alpine 為最小可用基底
# -----------------------------------------------------------------------------
# 宣告可覆寫的建置參數 NODE_VERSION,預設值 lts-alpine
ARG NODE_VERSION=lts-alpine
# 以 node:${NODE_VERSION} 作為基底映像;引用上方 ARG 決定實際 node 版本/變體
FROM node:${NODE_VERSION}
# -----------------------------------------------------------------------------
# 2. 安裝套件:主程式無第三方相依,亦未呼叫外部執行檔
# (不需 curl/jq/git 等 OS 套件),故略過此步驟
# -----------------------------------------------------------------------------
# 設定後續指令的工作目錄為 /app;不存在時會自動建立,COPY 的相對目的地以此為基準
WORKDIR /app
# -----------------------------------------------------------------------------
# 3. 複製檔案:主程式(app/)與啟動腳本
# -----------------------------------------------------------------------------
# 複製 app/ 目錄全部內容到映像內 /app/(主程式,含 index.js 進入點;須與 entrypoint.sh 的 /app/index.js 一致)
COPY app/ /app/
# 複製啟動腳本到映像根目錄 /entrypoint.sh(供 ENTRYPOINT 使用)
COPY entrypoint.sh /entrypoint.sh
# -----------------------------------------------------------------------------
# 4. 執行程序:賦予啟動腳本執行權限
# - 無 buildtranspile 需求,故不執行建置
# -----------------------------------------------------------------------------
# 對 /entrypoint.sh 加上可執行權限,確保容器啟動時能直接執行該腳本
RUN chmod +x /entrypoint.sh
# -----------------------------------------------------------------------------
# 5. 縮小映像檔:無相依、無 build 產物可裁剪,alpine 單階段即為最小映像,
# 多階段建置在此無縮小效益,故不採用
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# 6. 設定入口:以 entrypoint.sh 啟動(其內 node 指向 /app/index.js
# -----------------------------------------------------------------------------
# 設定容器進入點為 /entrypoint.sh(exec 形式);容器啟動即執行該腳本
ENTRYPOINT ["/entrypoint.sh"]