Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement --cache-from #209

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -56,6 +57,7 @@ type buildCommand struct {
labels stringSlice
target string
tags stringSlice
cacheFrom stringSlice

contextDir string
noConsole bool
Expand Down Expand Up @@ -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"] = ""
}
Expand Down