Proposal: Expose Git information via build args
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 682
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 29
Description
This proposal builds upon the existing Git labels feature (#1290) which attaches Git metadata to images via labels.
Problem Statement
Currently, there's no simple way to access Git metadata during the build process or at runtime, as the BUILDX_GIT_LABELS feature only adds labels to the final image, they are not accessible during the build process.
Proposed Solution
Add a new config variable, (e.g. BUILDX_GIT_ARGS) that would expose the same Git metadata as build args, making them available during the build process. The build args would be similar to the existing labels:
| Label | Build Arg |
|---|---|
com.docker.image.source.entrypoint |
SOURCEDOCKERFILE |
org.opencontainers.image.revision |
GITREVISION |
org.opencontainers.image.source |
GITSOURCE |
This follows the same naming pattern as other automatic arguments like BUILDPLATFORM, TARGETARCH, etc.
Implementation
Similar to BUILDX_GIT_LABELS, this would be opt-in via an environment variable and would only work when building from a context with a .git directory.
Example Use Cases
- Conditional build logic based on Git state
- Skip certain build steps when building from a "dirty" Git state
- Build-time decisions based on repository information
- Include debug symbols only for development branches
- Version stamping during build process
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing Git labels feature in issue #1290 and the BUILDX_GIT_LABELS environment-variable path; compare how Git metadata is exposed as image labels with the proposed build-time inputs. Done means an agreed opt-in BUILDX_GIT_ARGS behavior covering the listed metadata and the .git context requirement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100