fix: include .git in Docker build context for version embedding#1621
fix: include .git in Docker build context for version embedding#1621joanestebanr wants to merge 9 commits into
Conversation
This reverts commit 184bb40.
Removing .git/ from .dockerignore allows git describe/rev-parse to run inside the builder stage, so the binary gets correct Version, GitRev and GitBranch values without requiring build-args. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @joanestebanr's task in 1m 57s —— View job PR Review Complete ✅🚀 What's NewThis PR fixes version embedding in Docker builds by removing 🐛 Bug Fixes
📋 Config UpdatesNone.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 549aea0c97
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR restores Docker image version embedding by making git metadata available inside the Docker build, reverting the prior build-arg-based approach (PR #1619).
Changes:
- Removes
.git/from.dockerignoresogit describe/git rev-parsework during the builder stage. - Reverts Docker build targets and Dockerfile away from passing version build args / declaring version ARGs.
- Updates
go.mod/go.sumwith several indirectgolang.org/x/*version changes (appears unrelated to the stated goal).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
version.mk |
Reverts VERSION/GITREV/GITBRANCH to be computed via git at build time. |
Makefile |
Removes VERSION/GITREV/GITBRANCH build-args and drops the post-build version verification. |
Dockerfile |
Removes VERSION/GITREV/GITBRANCH ARG declarations from the builder stage. |
.dockerignore |
Stops excluding .git/ so git metadata is available inside Docker builds. |
go.mod |
Downgrades several indirect golang.org/x/* dependencies. |
go.sum |
Updates sums consistent with the indirect dependency downgrades. |
Comments suppressed due to low confidence (1)
go.mod:220
- Additional
golang.org/x/*indirect dependency downgrades are included here (x/sys,x/telemetry,x/text,x/tools). If the intent is only to change Docker build context/version embedding, these dependency changes should likely be dropped or called out explicitly with rationale.
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/telemetry v0.0.0-20260109210033-bd525da824e2 // indirect
golang.org/x/text v0.34.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.41.0 // indirect
Upgrades golang.org/x/crypto, net, sys, text, tools, mod and telemetry to their latest versions to address known security vulnerabilities. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
After each platform/variant build, pulls the image by digest and runs `aggkit version`, failing the job if the Version field is empty. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Restore .git/ to .dockerignore but re-include only the files required by git describe and git rev-parse (HEAD, packed-refs, refs/), so the auth token that actions/checkout writes to .git/config is never sent to the Docker daemon or stored in build cache. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors the same check added to release.yml: after each platform/variant build, pulls the image by digest and runs `aggkit version`, failing the job if the Version field is empty. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors the same check added to release.yml and build-push-docker-image.yml: after the make build-docker step, runs `aggkit version` and fails if the Version field is empty. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rather than trying to re-include individual git metadata files via negation patterns, keep .git/ accessible for git describe/rev-parse and only exclude .git/config where actions/checkout stores its auth token. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|



🔄 Changes Summary
docker/build-push-actionwas not updated to pass the version build-args)..git/from.dockerignoreso thatgit describeandgit rev-parserun correctly inside the builder stage, embedding the correctVersion,GitRevandGitBranchvalues in the binary without any changes to the Makefile, Dockerfile, or CI workflow.📋 Config Updates
✅ Testing
make build-docker && docker run aggkit:local versionshows correctVersion,Git revisionandGit branchfields.🐞 Issues
📝 Notes
.git/was excluded from the Docker context for security and context-size reasons. Since the builder stage only uses git metadata to set ldflags and the.gitdirectory is not copied into the final runtime image, the security concern does not apply.🤖 Generated with Claude Code