mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-22 20:20:39 +00:00
Merge pull request #119 from jmccann/remove_temp_layers
Remove temp tag from build and prune afterwards
This commit is contained in:
commit
4904d5cf56
11
plugin.go
11
plugin.go
@ -112,7 +112,7 @@ func (p Plugin) Exec() error {
|
|||||||
var cmds []*exec.Cmd
|
var cmds []*exec.Cmd
|
||||||
cmds = append(cmds, commandVersion()) // docker version
|
cmds = append(cmds, commandVersion()) // docker version
|
||||||
cmds = append(cmds, commandInfo()) // docker info
|
cmds = append(cmds, commandInfo()) // docker info
|
||||||
cmds = append(cmds, commandDockerPrune()) // cleanup docker
|
|
||||||
cmds = append(cmds, commandBuild(p.Build)) // docker build
|
cmds = append(cmds, commandBuild(p.Build)) // docker build
|
||||||
|
|
||||||
for _, tag := range p.Build.Tags {
|
for _, tag := range p.Build.Tags {
|
||||||
@ -123,6 +123,9 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
|
||||||
|
cmds = append(cmds, commandPrune()) // docker system prune -f
|
||||||
|
|
||||||
// execute all commands in batch mode.
|
// execute all commands in batch mode.
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
@ -291,10 +294,14 @@ func commandDaemon(daemon Daemon) *exec.Cmd {
|
|||||||
return exec.Command(dockerdExe, args...)
|
return exec.Command(dockerdExe, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func commandDockerPrune() *exec.Cmd {
|
func commandPrune() *exec.Cmd {
|
||||||
return exec.Command(dockerExe, "system", "prune", "-f")
|
return exec.Command(dockerExe, "system", "prune", "-f")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func commandRmi(tag string) *exec.Cmd {
|
||||||
|
return exec.Command(dockerExe, "rmi", tag)
|
||||||
|
}
|
||||||
|
|
||||||
// trace writes each command to stdout with the command wrapped in an xml
|
// trace writes each command to stdout with the command wrapped in an xml
|
||||||
// tag so that it can be extracted and displayed in the logs.
|
// tag so that it can be extracted and displayed in the logs.
|
||||||
func trace(cmd *exec.Cmd) {
|
func trace(cmd *exec.Cmd) {
|
||||||
|
Loading…
Reference in New Issue
Block a user