diff --git a/plugin.go b/plugin.go index c0e97ee..78ac379 100644 --- a/plugin.go +++ b/plugin.go @@ -112,7 +112,7 @@ func (p Plugin) Exec() error { var cmds []*exec.Cmd cmds = append(cmds, commandVersion()) // docker version cmds = append(cmds, commandInfo()) // docker info - cmds = append(cmds, commandDockerPrune()) // cleanup docker + cmds = append(cmds, commandBuild(p.Build)) // docker build 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. for _, cmd := range cmds { cmd.Stdout = os.Stdout @@ -291,10 +294,14 @@ func commandDaemon(daemon Daemon) *exec.Cmd { return exec.Command(dockerdExe, args...) } -func commandDockerPrune() *exec.Cmd { +func commandPrune() *exec.Cmd { 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 // tag so that it can be extracted and displayed in the logs. func trace(cmd *exec.Cmd) {