Skip to content

Commit

Permalink
Merge pull request #337 from tonistiigi/cacheonly-exporter
Browse files Browse the repository at this point in the history
build: support cacheonly exporter
  • Loading branch information
tonistiigi authored Jul 30, 2020
2 parents f2cf7cf + 3862ff2 commit 38f9241
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,13 @@ func toSolveOpt(d driver.Driver, multiDriver bool, opt Options, dl dockerLoadCal
IsDefaultMobyDriver()
})

noDefaultLoad, _ := strconv.ParseBool(os.Getenv("BUILDX_NO_DEFAULT_LOAD"))

switch len(opt.Exports) {
case 1:
// valid
case 0:
if isDefaultMobyDriver {
if isDefaultMobyDriver && !noDefaultLoad {
// backwards compat for docker driver only:
// this ensures the build results in a docker image.
opt.Exports = []client.ExportEntry{{Type: "image", Attrs: map[string]string{}}}
Expand Down Expand Up @@ -382,6 +384,15 @@ func toSolveOpt(d driver.Driver, multiDriver bool, opt Options, dl dockerLoadCal
}
}

// cacheonly is a fake exporter to opt out of default behaviors
exports := make([]client.ExportEntry, 0, len(opt.Exports))
for _, e := range opt.Exports {
if e.Type != "cacheonly" {
exports = append(exports, e)
}
}
opt.Exports = exports

// set up exporters
for i, e := range opt.Exports {
if (e.Type == "local" || e.Type == "tar") && opt.ImageIDFile != "" {
Expand Down

0 comments on commit 38f9241

Please sign in to comment.