Skip to content

Commit

Permalink
Docker workflow: keep .git in build context
Browse files Browse the repository at this point in the history
By default, BuildKit checks out the git repository but does not include the
.git directory in the build context. This then prevents go build from embedding
the commit hash into the binary which we want to include in the --version
output. This behavior can be changed by setting a build argument and fixes our
--version output.
  • Loading branch information
julianbrost committed Jul 25, 2024
1 parent 8928673 commit 8102c77
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ jobs:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
# Keep the .git to allow including the commit in the --version output, see also:
# https://docs.docker.com/build/building/context/#keep-git-directory
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1

0 comments on commit 8102c77

Please sign in to comment.