From 4987d0bbc6367812c024b323856e9e4e2f3bfbc4 Mon Sep 17 00:00:00 2001 From: Nao YONASHIRO Date: Wed, 9 Jan 2019 01:47:28 +0900 Subject: [PATCH] feat: implement --cache-from --- build.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.go b/build.go index 6dbe8d6e5..e9b41aa3e 100644 --- a/build.go +++ b/build.go @@ -48,6 +48,7 @@ func (cmd *buildCommand) Register(fs *flag.FlagSet) { fs.Var(&cmd.labels, "label", "Set metadata for an image") fs.BoolVar(&cmd.noConsole, "no-console", false, "Use non-console progress UI") fs.BoolVar(&cmd.noCache, "no-cache", false, "Do not use cache when building the image") + fs.Var(&cmd.cacheFrom, "cache-from", "Images to consider as cache sources") } type buildCommand struct { @@ -56,6 +57,7 @@ type buildCommand struct { labels stringSlice target string tags stringSlice + cacheFrom stringSlice contextDir string noConsole bool @@ -136,6 +138,10 @@ func (cmd *buildCommand) Run(ctx context.Context, args []string) (err error) { "filename": filepath.Base(cmd.dockerfilePath), "target": cmd.target, } + + cacheFrom := append([]string{}, cmd.cacheFrom...) + frontendAttrs["cache-from"] = strings.Join(cacheFrom, ",") + if cmd.noCache { frontendAttrs["no-cache"] = "" }