0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-25 09:10: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:
Brad Rydzewski 2017-05-15 16:43:43 +02:00 committed by GitHub
commit 4904d5cf56

View File

@ -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) {