Skip to content

Commit

Permalink
Merge pull request #1633 from wangyumu/add-buildkit-syntax-build-arg
Browse files Browse the repository at this point in the history
build-arg add support BUILDKIT_SYNTAX
  • Loading branch information
tonistiigi authored Aug 24, 2020
2 parents 1b350e4 + 882fc73 commit 898d720
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/dockerfile/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?://`)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 898d720

Please sign in to comment.