mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-10 03:30:40 +00:00
add cache-from
This commit is contained in:
parent
9589237541
commit
a48b59645a
@ -150,6 +150,10 @@ func main() {
|
|||||||
Name: "target",
|
Name: "target",
|
||||||
Usage: "build target",
|
Usage: "build target",
|
||||||
EnvVar: "PLUGIN_TARGET",
|
EnvVar: "PLUGIN_TARGET",
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "cache-from",
|
||||||
|
Usage: "cache from",
|
||||||
|
EnvVar: "PLUGIN_CACHE_FROM",
|
||||||
},
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "squash",
|
Name: "squash",
|
||||||
@ -245,6 +249,7 @@ func run(c *cli.Context) error {
|
|||||||
Target: c.String("target"),
|
Target: c.String("target"),
|
||||||
Squash: c.Bool("squash"),
|
Squash: c.Bool("squash"),
|
||||||
Pull: c.BoolT("pull-image"),
|
Pull: c.BoolT("pull-image"),
|
||||||
|
CacheFrom: c.String("cache-from"),
|
||||||
Compress: c.Bool("compress"),
|
Compress: c.Bool("compress"),
|
||||||
Repo: c.String("repo"),
|
Repo: c.String("repo"),
|
||||||
Labels: c.StringSlice("custom-labels"),
|
Labels: c.StringSlice("custom-labels"),
|
||||||
|
17
docker.go
17
docker.go
@ -47,6 +47,7 @@ type (
|
|||||||
Target string // Docker build target
|
Target string // Docker build target
|
||||||
Squash bool // Docker build squash
|
Squash bool // Docker build squash
|
||||||
Pull bool // Docker build pull
|
Pull bool // Docker build pull
|
||||||
|
CacheFrom string // Docker build cache-from
|
||||||
Compress bool // Docker build compress
|
Compress bool // Docker build compress
|
||||||
Repo string // Docker build repository
|
Repo string // Docker build repository
|
||||||
LabelSchema []string // label-schema Label map
|
LabelSchema []string // label-schema Label map
|
||||||
@ -104,6 +105,15 @@ func (p Plugin) Exec() error {
|
|||||||
fmt.Println("Registry credentials not provided. Guest mode enabled.")
|
fmt.Println("Registry credentials not provided. Guest mode enabled.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pre-pull cache image
|
||||||
|
if p.Build.CacheFrom != "" {
|
||||||
|
cmd := commandPull(p.Build.CacheFrom)
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
trace(cmd)
|
||||||
|
cmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
if p.Build.Squash && !p.Daemon.Experimental {
|
if p.Build.Squash && !p.Daemon.Experimental {
|
||||||
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
|
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
|
||||||
p.Build.Squash = false
|
p.Build.Squash = false
|
||||||
@ -162,6 +172,10 @@ func commandLogin(login Login) *exec.Cmd {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func commandPull(repo string) *exec.Cmd {
|
||||||
|
return exec.Command(dockerExe, "pull", repo)
|
||||||
|
}
|
||||||
|
|
||||||
func commandLoginEmail(login Login) *exec.Cmd {
|
func commandLoginEmail(login Login) *exec.Cmd {
|
||||||
return exec.Command(
|
return exec.Command(
|
||||||
dockerExe, "login",
|
dockerExe, "login",
|
||||||
@ -204,6 +218,9 @@ func commandBuild(build Build) *exec.Cmd {
|
|||||||
if build.NoCache {
|
if build.NoCache {
|
||||||
args = append(args, "--no-cache")
|
args = append(args, "--no-cache")
|
||||||
}
|
}
|
||||||
|
if build.CacheFrom != "" {
|
||||||
|
args = append(args, "--cache-from", build.CacheFrom)
|
||||||
|
}
|
||||||
for _, arg := range build.ArgsEnv {
|
for _, arg := range build.ArgsEnv {
|
||||||
addProxyValue(&build, arg)
|
addProxyValue(&build, arg)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user