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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion meta.jq
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,28 @@ def pull_command:
end
;
# input: "build" object (with "buildId" top level key)
# output: string "giturl" ("https://github.com/docker-library/golang.git#commit:directory), used for "docker buildx build giturl"
def git_build_url:
.source.entry
| (
.GitRepo
| if (endswith(".git") | not) then
if test("^https?://github.com/") then
# 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
# https://github.com/docker/cli/issues/1738
. + ".git"
else
error("\(.) does not end in '.git' so build will fail to recognize it as a Git URL")
end
else . end
) + "#" + .GitCommit + ":" + .Directory
;
# input: "build" object (with "buildId" top level key)
# output: string "build command" ("docker buildx build ..."), may be multiple lines, expects to run in Bash with "set -Eeuo pipefail"
def build_command:
normalized_builder as $builder
| (.source.entry.GitRepo + "#" + .source.entry.GitCommit + ":" + .source.entry.Directory) as $buildUrl
| git_build_url as $buildUrl
| if $builder == "buildkit" then
[
(
Expand Down