From 7d92f2d6ad57a77537ac2b06900fa7f383ceffdc Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 30 Oct 2018 17:48:31 +0900 Subject: [PATCH] buildctl: support --no-cache for Dockerfile frontend Signed-off-by: Akihiro Suda --- cmd/buildctl/build.go | 6 ++---- examples/build-using-dockerfile/main.go | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/buildctl/build.go b/cmd/buildctl/build.go index a82a5b81..0b246ea3 100644 --- a/cmd/buildctl/build.go +++ b/cmd/buildctl/build.go @@ -61,7 +61,7 @@ var buildCommand = cli.Command{ }, cli.BoolFlag{ Name: "no-cache", - Usage: "Disable cache for all the vertices. Frontend is not supported.", + Usage: "Disable cache for all the vertices", }, cli.StringFlag{ Name: "export-cache", @@ -218,9 +218,7 @@ func build(clicontext *cli.Context) error { return err } } else { - if clicontext.Bool("no-cache") { - return errors.New("no-cache is not supported for frontends") - } + solveOpt.FrontendAttrs["no-cache"] = "" } eg.Go(func() error { diff --git a/examples/build-using-dockerfile/main.go b/examples/build-using-dockerfile/main.go index 5ae7688b..12fa8439 100644 --- a/examples/build-using-dockerfile/main.go +++ b/examples/build-using-dockerfile/main.go @@ -63,6 +63,10 @@ By default, the built image is loaded to Docker. Name: "target", Usage: "Set the target build stage to build.", }, + cli.BoolFlag{ + Name: "no-cache", + Usage: "Do not use cache when building the image", + }, }, dockerIncompatibleFlags...) app.Action = action if err := app.Run(os.Args); err != nil { @@ -145,7 +149,9 @@ func newSolveOpt(clicontext *cli.Context, w io.WriteCloser) (*client.SolveOpt, e if target := clicontext.String("target"); target != "" { frontendAttrs["target"] = target } - + if clicontext.Bool("no-cache") { + frontendAttrs["no-cache"] = "" + } for _, buildArg := range clicontext.StringSlice("build-arg") { kv := strings.SplitN(buildArg, "=", 2) if len(kv) != 2 {