Skip to content

Commit

Permalink
Workaround "docker build giturl" requiring the url to end in ".git"
Browse files Browse the repository at this point in the history
  • Loading branch information
yosifkit committed Jan 18, 2024
1 parent 1dd5f0a commit 4daf4a2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion meta.jq
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,24 @@ def pull_command:
end
;
# input: "build" object (with "buildId" top level key)
# output: string "giturl" ("https://github.com/docker-library/golang#commit:directory), used for "docker build giturl"
def git_build_url:
.source.entry.GitRepo as $gitRepo
| if ($gitRepo | test("^https?://github.com/"))
and ($gitRepo | endswith(".git") | not) then
# 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
$gitRepo + ".git"
else
$gitRepo
end
+ "#" + .source.entry.GitCommit + ":" + .source.entry.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

0 comments on commit 4daf4a2

Please sign in to comment.