Remove temp tag from build and prune afterwards

This commit is contained in:
Jacob McCann 2017-03-22 07:18:40 -05:00
parent 1eebf96ce4
commit 6e9fe40cd7

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