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

Workaround "docker build giturl" requiring the url to end in ".git" #15

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

yosifkit
Copy link
Member

Requirements like in moby/buildkit git_ref.go (even though git URLs don't need to end in .git).

@yosifkit yosifkit requested a review from tianon as a code owner January 18, 2024 01:07
meta.jq Outdated Show resolved Hide resolved
meta.jq Outdated
Comment on lines 61 to 62
# without ".git" in the url "docker build url" fails and tries to build the html repo page as a Dockerfile
# https://github.com/moby/moby/blob/4f9c865eddc09da0c0cb9fe08c76b81b804093f5/builder/remotecontext/urlutil/urlutil.go#L15
Copy link
Member

Choose a reason for hiding this comment

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

(included in the better later suggestion)

Suggested change
# without ".git" in the url "docker build url" fails and tries to build the html repo page as a Dockerfile
# https://github.com/moby/moby/blob/4f9c865eddc09da0c0cb9fe08c76b81b804093f5/builder/remotecontext/urlutil/urlutil.go#L15
# without ".git" in the url "docker buildx build url" fails and tries to build the html repo page as a Dockerfile
# https://github.com/moby/buildkit/blob/0e1e36ba9eb8142968b2c5cfa2f12549bf9246d9/util/gitutil/git_ref.go#L81-L87

Copy link
Collaborator

Choose a reason for hiding this comment

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

That regular expression is ".git(?:#.+)?$", which allows for anchors while ($gitRepo | endswith(".git") | not) does not. Is this okay?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is fine being stricter than docker build. And the newer link from buildkit is also stricter and is the one we'll hit (since we are doing docker buildx build).

Copy link
Collaborator

@whalelines whalelines Jan 18, 2024

Choose a reason for hiding this comment

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

It appears that BuildKit code parses the URL and matches specifically on the Path portion of the URL, which does not include any query or fragment portions of the URL.

But perhaps there are not uses of queries or fragments in the bashbrew files.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't think git clone on a URL with a query parameter would actually work correctly, but maybe there's some esoteric server somewhere? I'm not worried about the regex being .git because that's just a bug (a 6 year old bug, to be fair, so could be considered "load bearing", but BuildKit implemented the same check more correctly and nobody's noticed, so I don't think anyone's put real load on it)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, and the anchors are a Docker-ism and we generate the correct anchor lower down in this file (git clone doesn't support anchors and they're a Docker-ism specifically to specify -b and a directory path).

Copy link
Member

Choose a reason for hiding this comment

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

(In other words, any GitRepo: with an anchor in it would be invalid already)

meta.jq Outdated Show resolved Hide resolved
meta.jq Outdated Show resolved Hide resolved
@tianon
Copy link
Member

tianon commented Jan 18, 2024

Aha! docker/cli#1738

@LaurentGoderre
Copy link
Member

@tianon tianon merged commit 19ca057 into docker-library:main Jan 18, 2024
1 check passed
@tianon tianon deleted the git-url-bug branch January 18, 2024 18:01
@tianon
Copy link
Member

tianon commented Jan 18, 2024

Yay https://github.com/docker-library/meta/actions/runs/7574232353/job/20628160728 🎉

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.

4 participants