Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Expose Git information via build args #2784

Open
mschfh opened this issue Nov 8, 2024 · 0 comments
Open

Proposal: Expose Git information via build args #2784

mschfh opened this issue Nov 8, 2024 · 0 comments

Comments

@mschfh
Copy link

mschfh commented Nov 8, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant