diff --git a/frontend/dockerfile/builder/build.go b/frontend/dockerfile/builder/build.go index eb868f7d137f..04d27f215bb5 100644 --- a/frontend/dockerfile/builder/build.go +++ b/frontend/dockerfile/builder/build.go @@ -53,6 +53,7 @@ const ( keyNameDockerfile = "dockerfilekey" keyContextSubDir = "contextsubdir" keyContextKeepGitDir = "build-arg:BUILDKIT_CONTEXT_KEEP_GIT_DIR" + keySyntax = "build-arg:BUILDKIT_SYNTAX" ) var httpPrefix = regexp.MustCompile(`^https?://`) @@ -317,8 +318,14 @@ func Build(ctx context.Context, c client.Client) (*client.Result, error) { } if _, ok := opts["cmdline"]; !ok { - ref, cmdline, loc, ok := dockerfile2llb.DetectSyntax(bytes.NewBuffer(dtDockerfile)) - if ok { + if cmdline, ok := opts[keySyntax]; ok { + p := strings.SplitN(strings.TrimSpace(cmdline), " ", 2) + res, err := forwardGateway(ctx, c, p[0], cmdline) + if err != nil && len(errdefs.Sources(err)) == 0 { + return nil, errors.Wrapf(err, "failed with %s = %s", keySyntax, cmdline) + } + return res, err + } else if ref, cmdline, loc, ok := dockerfile2llb.DetectSyntax(bytes.NewBuffer(dtDockerfile)); ok { res, err := forwardGateway(ctx, c, ref, cmdline) if err != nil && len(errdefs.Sources(err)) == 0 { return nil, wrapSource(err, sourceMap, loc)