Skip to content
Closed
Show file tree
Hide file tree
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
22 changes: 15 additions & 7 deletions build/opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1120,19 +1120,20 @@ func createTempDockerfile(r io.Reader, multiReader *SyncMultiReader) (string, er
}

func processGitURL(url string, name string, target *client.SolveOpt, caps map[string]struct{}) error {
gitRef, err := gitutil.ParseURL(url)
gitURL, err := gitutil.ParseURL(url)
if err != nil {
return err
}
if len(gitRef.Query) == 0 {
if len(gitURL.Query) == 0 {
return nil
}
if gitRef, ok, err := dfgitutil.ParseGitRef(url); err != nil && ok {
return err
} else if ok && gitRef.FetchByCommit {
addFrontendCap(caps, "moby.buildkit.frontend.gitfetchbycommit", name)
}
if !sendGitQueryAsInput() {
capName := "moby.buildkit.frontend.gitquerystring"
if name != "context" {
capName += "+forward"
}
caps[capName] = struct{}{}
addFrontendCap(caps, "moby.buildkit.frontend.gitquerystring", name)
return nil
}

Expand Down Expand Up @@ -1170,6 +1171,13 @@ func processGitURL(url string, name string, target *client.SolveOpt, caps map[st
return nil
}

func addFrontendCap(caps map[string]struct{}, capName, name string) {
if name != "context" {
capName += "+forward"
}
caps[capName] = struct{}{}
}

// handle https://github.com/moby/moby/pull/10858
func handleLowercaseDockerfile(dir, p string) string {
if filepath.Base(p) != "Dockerfile" {
Expand Down
5 changes: 5 additions & 0 deletions commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,11 @@ func wrapBuildError(err error, bake bool) error {
msg += " Git URLs with query string are supported since Dockerfile v1.18 and BuildKit v0.24. Use BUILDKIT_SYNTAX build-arg, #syntax directive in Dockerfile or update to latest BuildKit."
return &wrapped{err, msg}
}
if st.Code() == codes.Unimplemented && strings.Contains(st.Message(), "unsupported frontend capability moby.buildkit.frontend.gitfetchbycommit") {
msg := "current frontend does not support Git URLs with fetch-by-commit query attribute."
msg += " Git URLs with fetch-by-commit with query attribute are supported since Dockerfile v1.24 and BuildKit v0.30. Use BUILDKIT_SYNTAX build-arg, #syntax directive in Dockerfile or update to latest BuildKit."
return &wrapped{err, msg}
}
}
return err
}
Expand Down
Loading