Docker 中 Codex CLI 独立更新方案
1. 设计理念
Codex CLI 更新频繁,而 ROOT、Geant4、Python 等科研环境相对稳定。
因此将三部分解耦:
research-dev-base = 稳定科研基础环境 codex-runtime = Codex CLI 程序 codex-profile = Codex 用户配置、认证和登录状态运行关系:
research-dev-base │ ▼ wiki-dev │ ├── /opt/codex │ ↑ │ codex-runtime │ RO │ └── /root/.codex ↑ codex-profile RW原则:
research-dev-base不随 Codex 版本更新。codex-runtime专门保存 Codex CLI,可独立升级。codex-profile保存config.toml、认证信息等长期状态。wiki-dev只读使用codex-runtime。codex-updater负责以 RW 方式更新codex-runtime。
因此:
Codex 升级 → 只更新 codex-runtime 不会影响: → research-dev-base → ROOT / Geant4 / Python → wiki 工作区 → codex-profile2. 版本管理
Codex 版本由:
E:\imp\wiki-docker-runtime\.env控制:
CODEX_VERSION=xxx升级 Codex 本质上就是:
修改 CODEX_VERSION ↓ 运行 codex-updater ↓ 更新 codex-runtime ↓ wiki-dev 使用新版本3. Codex 更新方法
进入 Runtime:
cd E:\imp\wiki-docker-runtime修改版本,例如:
(Get-Content.env)`-replace'CODEX_VERSION=.*','CODEX_VERSION=xxx'|Set-Content.env执行更新:
docker compose--profile updater run--rmcodex-updater检查版本:
docker compose exec wiki-dev codex--version如果仍显示旧版本:
docker compose restart wiki-dev docker compose exec wiki-dev codex--version4. 检查 Compose 读取的版本
docker compose--profile updater config|Select-String"CODEX_VERSION"应看到:
CODEX_VERSION: xxx5. 日常升级流程
以后升级 Codex 只需要:
cd E:\imp\wiki-docker-runtime(Get-Content.env)`-replace'CODEX_VERSION=.*','CODEX_VERSION=<新版本>'|Set-Content.env docker compose--profile updater run--rmcodex-updater docker compose exec wiki-dev codex--version必要时:
docker compose restart wiki-dev6. 核心思想
整个设计只有一个目的:
将稳定的科研环境、高频更新的 Codex CLI、长期保存的用户配置分离管理。
稳定环境 research-dev-base + 高频程序 codex-runtime + 长期状态 codex-profile这样升级 Codex 不需要重建大型科研镜像,也不会影响科研环境和用户配置。