Skip to content

Commit 4c9a902

Browse files
committed
Add support for cache-to in build process
1 parent 4d9dc35 commit 4c9a902

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cmd/drone-docker/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ func main() {
183183
Usage: "images to consider as cache sources",
184184
EnvVar: "PLUGIN_CACHE_FROM",
185185
},
186+
cli.StringFlag{
187+
Name: "cache-to",
188+
Usage: "images to consider as cache stores",
189+
EnvVar: "PLUGIN_CACHE_TO",
190+
},
186191
cli.BoolFlag{
187192
Name: "squash",
188193
Usage: "squash the layers at build time",
@@ -370,6 +375,7 @@ func run(c *cli.Context) error {
370375
Squash: c.Bool("squash"),
371376
Pull: c.BoolT("pull-image"),
372377
CacheFrom: c.StringSlice("cache-from"),
378+
CacheTo: c.String("cache-to"),
373379
Compress: c.Bool("compress"),
374380
Repo: c.String("repo"),
375381
Labels: c.StringSlice("custom-labels"),

docker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type (
6161
Squash bool // Docker build squash
6262
Pull bool // Docker build pull
6363
CacheFrom []string // Docker build cache-from
64+
CacheTo string // Docker build cache-to
6465
Compress bool // Docker build compress
6566
Repo string // Docker build repository
6667
LabelSchema []string // label-schema Label map
@@ -414,6 +415,9 @@ func commandBuild(build Build) *exec.Cmd {
414415
for _, arg := range build.CacheFrom {
415416
args = append(args, "--cache-from", arg)
416417
}
418+
if build.CacheTo != "" {
419+
args = append(args, "--cache-to", build.CacheTo)
420+
}
417421
for _, arg := range build.ArgsEnv {
418422
addProxyValue(&build, arg)
419423
}

0 commit comments

Comments
 (0)