docs(README 與 CD workflow): 重建 README 並為 cd.yaml 補逐行註解

This commit is contained in:
Jeffery
2026-06-30 12:13:29 +08:00
parent 4622ff3001
commit 5058a5dd4a
2 changed files with 128 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
# codex
> 更新時間(Asia/Taipei):2026/06/30 12:04:48
以多階段建置(multi-stage build)打包 [@openai/codex](https://www.npmjs.com/package/@openai/codex) CLI 的 Docker 映像檔專案。build 階段於 `node:<版本>-slim` 透過 npm 全域安裝 codex CLIruntime 階段改用同樣精簡的 `node-slim` 基底,只帶入 codex 套件與其相依,並額外安裝 `ca-certificates` 以支援 HTTPS 連線,最終映像預設執行 `codex --version`。搭配 `.gitea/workflows/cd.yaml`,當 push 到 `master` 分支時,會自動釋出版本號、建置映像檔並推送到 Gitea 倉庫。
## 專案列表
### 專案描述
| 專案名稱 | 專案描述 |
| --- | --- |
| [codex](https://gitea.jsc.idv.tw/images/codex/src/branch/develop) | 以多階段建置打包 @openai/codex CLI 的 Docker 映像檔專案,提供 `Dockerfile` 與 Gitea Actions CD 流程;此專案未公開可列入 README 的功能。 |
### 參考專案
| 專案名稱 | 參考專案列表 |
| --- | --- |
| [codex](https://gitea.jsc.idv.tw/images/codex/src/branch/develop) | 無 |
### NuGet 套件
| 專案名稱 | NuGet 套件列表 |
| --- | --- |
| [codex](https://gitea.jsc.idv.tw/images/codex/src/branch/develop) | 無 |
## 功能列表
本專案為 Docker 映像檔建置專案,未公開可列入 README 的程式方法(public methodconstructorextension methodoperator)。實際交付內容為下列容器映像檔的建置與發佈設定,使用方式詳見「使用範例」。
## 使用範例
### 建置映像檔
於專案根目錄(含 `Dockerfile`)執行:
```bash
docker build -t codex .
```
- 預設使用 `node:22-slim` 作為 build 與 runtime 基底,並全域安裝 `@openai/codex`
- 建議啟用 BuildKit(檔首已宣告 `# syntax=docker/dockerfile:1`):`DOCKER_BUILDKIT=1 docker build -t codex .`
### 執行容器
```bash
# 顯示 codex 版本(映像檔預設 CMD)
docker run --rm codex
# 覆寫預設指令,改執行其他 codex 子指令
docker run --rm codex codex --help
```
### 以 build 參數覆寫預設值
`Dockerfile` 將可調參數集中於檔首 `ARG`,可於建置時覆寫:
```bash
# 指定 node 版本
docker build --build-arg NODE_VERSION=20 -t codex:node20 .
# 指定要安裝的 npm 套件(預設 @openai/codex
docker build --build-arg CODEX_PACKAGE=@openai/codex@latest -t codex:latest .
```
| 參數 | 預設值 | 說明 |
| --- | --- | --- |
| `NODE_VERSION` | `22` | node 基底映像版本(同時套用於 build 與 runtime 階段) |
| `BUILD_IMAGE` | `node:${NODE_VERSION}-slim` | build 階段基底映像 |
| `RUNTIME_IMAGE` | `node:${NODE_VERSION}-slim` | runtime 階段基底映像 |
| `CODEX_PACKAGE` | `@openai/codex` | 要全域安裝的 npm 套件名稱 |
### CI/CD 自動發佈(Gitea Actions
`.gitea/workflows/cd.yaml` 定義 CD 流程:當 push 到 `master` 分支時觸發,依序執行兩個 job
1. **Release Tag Version**:以共用 composite action 釋出並標註成品版本,輸出 `version`
2. **Docker Build & Push**checkout 原始碼 → 登入 `gitea.jsc.idv.tw` 倉庫(帳密來自 secrets)→ 以 `gitea.repository` 為映像名稱、上一步 `version` 為 tag 建置並推送映像檔。
> 對外契約(CI 倉庫位址 `gitea.jsc.idv.tw`、登入帳號、`secrets.TOKEN`、建置與推送指令)皆沿用原設定,未變更。