Skip to content

Conversation

@crazy-max
Copy link
Member

Fixes #3347
Closes #3348

cc @thaJeztah @tonistiigi

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
@codecov-commenter
Copy link

Codecov Report

Merging #3349 (83c2537) into master (e57b5f7) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #3349   +/-   ##
=======================================
  Coverage   58.01%   58.01%           
=======================================
  Files         302      302           
  Lines       21762    21762           
=======================================
  Hits        12625    12625           
  Misses       8215     8215           
  Partials      922      922           

@thaJeztah
Copy link
Member

Can we somehow make the builds work without having to copy the .git directory? It feels like this is hiding the actual issue (i.e., the build now needs the git repository, but effectively just to generate a version)

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you verify that the changes were only from ignored files? I have a vague memory that it was always the case because of generated code but maybe that has been already fixed. I think in releases we ignore it because of VERSION override.

Can we somehow make the builds work without having to copy the .git directory? It feels like this is hiding the actual issue (i.e., the build now needs the git repository, but effectively just to generate a version)

I don't see any issue with that. It is working correctly by letting us know that there was an issue with validating the source.

@crazy-max
Copy link
Member Author

@tonistiigi

Did you verify that the changes were only from ignored files? I have a vague memory that it was always the case because of generated code but maybe that has been already fixed. I think in releases we ignore it because of VERSION override.

Yes changes are from the ignored files only:

#16 1.680  D .circleci/config.yml
#16 1.680  D .dockerignore
#16 1.680  D .github/CODEOWNERS
#16 1.680  D .github/ISSUE_TEMPLATE.md
#16 1.680  D .github/PULL_REQUEST_TEMPLATE.md
#16 1.680  D .github/workflows/codeql-analysis.yml
#16 1.680  D .gitignore
#16 1.680  D appveyor.yml
#16 1.680  D cli/winresources/res_windows.go

Generated code is already taken into account and has also been fixed for cli/winresources since #3310.

Also not relevant to this PR, but was going to add BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 in the bake definition to remove the extra git clone step so we can use in the future:

docker buildx bake --set binary.platform=darwin/amd64 "git://github.com/docker/cli#v20.10.10"

@thaJeztah

Can we somehow make the builds work without having to copy the .git directory? It feels like this is hiding the actual issue (i.e., the build now needs the git repository, but effectively just to generate a version)

I think validating the working tree is important as part of the build so we make sure we don't miss something.

@thaJeztah
Copy link
Member

I think validating the working tree is important as part of the build so we make sure we don't miss something.

Including .git in the build-context will result in the build-cache being busted even if unrelated changes are made (e.g. creating a new branch, or making changes in another branch will result in changes inside the .git directory). In general, I don't think a build should depend on .git, they're separate concerns.

ericpromislow added a commit to rancher-sandbox/rancher-desktop-docker-cli that referenced this pull request Oct 25, 2021
Workaround for docker/cli#3349

Leaving in the commented-out code to reinstate once this docker bug is fixed.

Signed-off-by: Eric Promislow <epromislow@suse.com>
@tonistiigi
Copy link
Member

@thaJeztah If you want to get a cache match for the go build so that it only depends on go sources you can add a filter step in Dockerfile. In practice, I'm not sure if it is beneficial as that step is cached with cache mount already for incremental builds. As far as the build is concerned, all git files are part of the build as their state gets reported in the version output so the logic is correct.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get this one in, as it's not changing things w.r.t. what we already do (but possibly we should discuss some)

LGTM

@thaJeztah thaJeztah merged commit 0c8c20f into docker:master Nov 12, 2021
@crazy-max crazy-max deleted the fix-dockerignore branch November 12, 2021 15:05
@thaJeztah thaJeztah added this to the 22.06.0 milestone May 13, 2022
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

Successfully merging this pull request may close these issues.

Using docker buildx bake to build a binary at a tagged commit ends up with a X.Y.Z.m version

4 participants