fix(docker): Go 构建镜像跟上 go.mod 的 1.26.6(否则任一 Dockerfile 构建都直接失败) - #5690
Merged
Wei-Shaw merged 1 commit intoAug 17, 2026
Merged
Conversation
89d826b raised backend/go.mod to `go 1.26.6` and updated the three CI workflows' version assertions, but left the Go builder image in all three Dockerfiles pinned at 1.26.5. Since the official golang images set GOTOOLCHAIN=local, the toolchain is not auto-downloaded and any image build fails hard at `go mod download`. CI does not catch this: the workflows build with actions/setup-go, not with these Dockerfiles. Also extend the Go-upgrade checklist in DEV_GUIDE.md, which listed only the CI files -- that omission is why the Dockerfiles were missed.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
问题
v0.1.177起,用仓库里任意一个 Dockerfile 构建镜像都会直接失败:backend/go.mod已经要求go 1.26.6,而三个 Dockerfile 里的 Go 构建镜像还钉在1.26.5。官方 golang 镜像设置了GOTOOLCHAIN=local,不会自动下载更新的工具链,于是在go mod download这步硬失败。复现步骤
git checkout v0.1.177 docker build -t sub2api:test .backend-builder阶段报上面那个错,退出码 1deploy/Dockerfile与backend/Dockerfile同理。临时绕过办法(对根
Dockerfile和deploy/Dockerfile有效,因为它们把版本写成了ARG):docker build --build-arg GOLANG_IMAGE=golang:1.26.6-alpine -t sub2api:test .backend/Dockerfile是FROM golang:1.26.5-alpine硬编码,没有这个口子。原因
89d826be2(修复:解决分组用量 PR 的 CI 失败,2026-08-14)把backend/go.mod提到了 1.26.6,并同步更新了三个 workflow 的版本断言,但没有动任何一个 Dockerfile:在此之前,两者一直是同步的:
backend/go.mod(
25a716960「Go 工具链升级 1.26.4 → 1.26.5」那次就是两边一起改的,所以这是一次回归,不是历来如此。)为什么 CI 发现不了
三个 workflow 都用
actions/setup-go+go-version-file: backend/go.mod取版本,跑的不是这些 Dockerfile;官方镜像发布走 goreleaser(在 runner 上编好二进制再塞进 alpine 基础镜像),也不经过backend-builder这条多阶段链。于是这条链路没有任何自动化覆盖,只有自行用仓库 Dockerfile 构建的人会撞上。
checklist 里漏了 Dockerfile
DEV_GUIDE.md里那条升级须知只列了 CI 文件:Dockerfile 不在清单里 —— 这才是这次漏改的直接原因,所以本 PR 一并把它补上。
修复
三个 Dockerfile 的 Go 构建镜像跟上
go.mod:DockerfileARG GOLANG_IMAGE=golang:1.26.5-alpine→1.26.6-alpinedeploy/Dockerfilebackend/DockerfileFROM golang:1.26.5-alpine→1.26.6-alpine并把
DEV_GUIDE.md的升级 checklist 补上这三个文件,同时点明两类遗漏的表现不同:关于「更省事的改法」
考虑过让 Dockerfile 从
go.mod派生版本(构建时grep '^go ' backend/go.mod)以杜绝再次漂移,没有采用:那需要在 Dockerfile 之外加一层包装或改变构建调用方式,对上游是侵入性改动;而仓库现有的做法(版本写死 + 文档 checklist)本来是有效的,这次只是 checklist 漏了一项。先把 checklist 补全,比改变构建模式更贴合现状。如果维护者更倾向于加一个 CI 检查(比对
go.mod与 Dockerfile 的版本,不一致就红),我可以另开一个 PR —— 本 PR 按「不改 CI 配置」的惯例没有涉及。测试
双向证据(实际构建,非推演):
GOLANG_IMAGE=golang:1.26.5-alpine)go mod download失败:go.mod requires go >= 1.26.6 (running go 1.26.5; GOTOOLCHAIN=local)golang:1.26.6-alpine)修复后的镜像已在实际环境运行验证:应用正常启动、
/health通、v0.1.177 的两个新迁移(222_group_usage_daily_rollups/223_group_usage_rollup_timezone)正常执行并落库。本 PR 不含任何 Go 代码改动(
git diff --name-only无.go文件),因此gofmt/go build/ 两档go test的结果与 base 完全一致。影响面
go.mod已经要求它,CI 也已经跑在这个版本上 —— 本 PR 只是让 Dockerfile 追上,不引入新的版本要求附带说明(本 PR 未处理)
README.md/README_CN.md/README_JA.md里的徽章和技术栈表格仍写着Go 1.26.5。那些是展示性内容、不影响构建,为避免在本 PR 里混入无关 diff 没有一并改。需要的话我另开一个文档 PR。