fix: inject PROXY_VERSION at Docker build time to fix stale version display (#676)#677
Open
icebear0828 wants to merge 5 commits into
Open
fix: inject PROXY_VERSION at Docker build time to fix stale version display (#676)#677icebear0828 wants to merge 5 commits into
icebear0828 wants to merge 5 commits into
Conversation
…isplay
Docker containers lack .git so getProxyInfo() falls back to package.json
which hasn't been bumped (still 2.0.77 while tag is 2.0.80).
Changes:
- Dockerfile: add ARG PROXY_VERSION + ENV PROXY_VERSION=${PROXY_VERSION}
- docker-publish.yml: pass build-args: PROXY_VERSION=<computed-version>
- src/self-update.ts: getProxyInfo() checks process.env.PROXY_VERSION first,
falls back to git-tag / package.json for non-Docker environments
Fixes #676
Owner
Author
Self-review Notes总体评价核心机制( 🔴 Must Fix1. CI smoke 未传
建议 smoke step 改为: run: |
PKG_VER=$(node -p "require('./package.json').version")
docker build -t codex-proxy:smoke --build-arg PROXY_VERSION=$PKG_VER .
docker run --rm codex-proxy:smoke node -e "const m=require('./dist/self-update.js'); const v=m.getProxyInfo().version; if(!v) process.exit(1); console.log('version:',v)"2. 缺少单元测试(违反项目 TDD 规范)
it("prefers PROXY_VERSION env over package.json", () => {
process.env.PROXY_VERSION = "9.9.9";
try {
expect(getProxyInfo().version).toBe("9.9.9");
} finally {
delete process.env.PROXY_VERSION;
}
});🟢 Low
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Docker 容器内没有
.git,所以getProxyInfo()只能读package.json。但package.json的 version 字段一直停在2.0.77(tag-only 发版策略不 bump package.json),导致容器始终显示旧版本。修复
DockerfileARG PROXY_VERSION+ENV PROXY_VERSION=${PROXY_VERSION}docker-publish.ymlbuild-args: PROXY_VERSION=<computed>src/self-update.tsgetProxyInfo()优先读process.env.PROXY_VERSION,无环境变量时回退 git-tag / package.json验证
Closes #676