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

Can't use ".git" folder as a build context #4846

Closed
tzachshabtay opened this issue Apr 15, 2024 · 2 comments · Fixed by #4849
Closed

Can't use ".git" folder as a build context #4846

tzachshabtay opened this issue Apr 15, 2024 · 2 comments · Fixed by #4849

Comments

@tzachshabtay
Copy link

When trying to use the local ".git" folder as a build context, I'm getting the error:

WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:15
--------------------
  13 |     
  14 |     # hadolint ignore=DL3022
  15 | >>> COPY --from=gitinfo . ./.git
  16 |     
--------------------
ERROR: failed to solve: invalid context specifier ../../../../.git for gitinfo
make: *** [Makefile:96: build-base] Error 1

I tried it with both a relative path and an absolute path, getting an errors both ways.
Using other folders (with the same permission set) works well, so the issue seems to be specific to the ".git" folder.

I can get it to work by downgrading buildx.
It works with version github.com/docker/buildx v0.10.2 00ed17d but fails with 0.13.1.

My command to build the image (from a makefile):

	export DOCKER_BUILDKIT=1
	@docker buildx build \
		--build-arg BUILDKIT_INLINE_CACHE=1 \
		--build-context gitinfo=../../../../.git \
		-t whatever \
		-f Dockerfile .

The dockerfile first line is # syntax=docker/dockerfile:1, also tried with # syntax=docker/dockerfile:1.4 and didn't make a difference.

I tried removing --build-arg BUILDKIT_INLINE_CACHE=1 and it didn't make a difference.

Docker version:

Client:
 Version:           20.10.23
 API version:       1.41
 Go version:        go1.18.10
 Git commit:        7155243
 Built:             Thu Jan 19 17:30:35 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Server: Docker Engine - Community
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.10
  Git commit:       311b9ff
  Built:            Thu Oct 26 09:05:28 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.7.6
  GitCommit:        091922f03c2762540fd057fba91260237ff86acb
 runc:
  Version:          1.1.9
  GitCommit:        v1.1.9-0-gccaecfc
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Might be related to: #4777

@tonistiigi
Copy link
Member

Might be related to: #4777

Yes, this looks to be related. Can you test with buildx 0.14-rc?

@tzachshabtay
Copy link
Author

  • With v0.14.0-rc1 it works if using a relative path but fails (with the same error) if using an absolute path.
  • With v0.13.1 it fails for both relative path and absolute path
  • With v0.10.12 it works for both relative path and absolute path

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 a pull request may close this issue.

2 participants