@@ -61,20 +61,22 @@ func commandBuildx() *exec.Cmd {
6161}
6262
6363// helper function to create the docker build command.
64- func commandBuild (build Build ) * exec.Cmd {
64+ func commandBuild (build Build , dryrun bool ) * exec.Cmd {
6565 args := []string {
6666 "buildx" ,
6767 "build" ,
6868 "--rm=true" ,
6969 "-f" , build .Dockerfile ,
70- "-t" , build .Name ,
7170 }
7271
7372 defaultBuildArgs := []string {
7473 fmt .Sprintf ("DOCKER_IMAGE_CREATED=%s" , time .Now ().Format (time .RFC3339 )),
7574 }
7675
7776 args = append (args , build .Context )
77+ if ! dryrun {
78+ args = append (args , "--push" )
79+ }
7880 if build .Squash {
7981 args = append (args , "--squash" )
8082 }
@@ -106,16 +108,14 @@ func commandBuild(build Build) *exec.Cmd {
106108 args = append (args , "--quiet" )
107109 }
108110
109- if len (build .Platforms .Value ()) > 1 {
110- args = append (args , "--push" )
111- } else {
112- args = append (args , "--load" )
113- }
114-
115111 if len (build .Platforms .Value ()) > 0 {
116112 args = append (args , "--platform" , strings .Join (build .Platforms .Value ()[:], "," ))
117113 }
118114
115+ for _ , arg := range build .Tags .Value () {
116+ args = append (args , "-t" , fmt .Sprintf ("%s:%s" , build .Repo , arg ))
117+ }
118+
119119 return exec .Command (dockerExe , args ... )
120120}
121121
@@ -162,23 +162,6 @@ func hasProxyBuildArg(build *Build, key string) bool {
162162 return false
163163}
164164
165- // helper function to create the docker tag command.
166- func commandTag (build Build , tag string ) * exec.Cmd {
167- var (
168- source = build .Name
169- target = fmt .Sprintf ("%s:%s" , build .Repo , tag )
170- )
171- return exec .Command (
172- dockerExe , "tag" , source , target ,
173- )
174- }
175-
176- // helper function to create the docker push command.
177- func commandPush (build Build , tag string ) * exec.Cmd {
178- target := fmt .Sprintf ("%s:%s" , build .Repo , tag )
179- return exec .Command (dockerExe , "push" , target )
180- }
181-
182165// helper function to create the docker daemon command.
183166func commandDaemon (daemon Daemon ) * exec.Cmd {
184167 args := []string {
@@ -216,24 +199,6 @@ func commandDaemon(daemon Daemon) *exec.Cmd {
216199 return exec .Command (dockerdExe , args ... )
217200}
218201
219- // helper to check if args match "docker prune"
220- func isCommandPrune (args []string ) bool {
221- return len (args ) > 3 && args [2 ] == "prune"
222- }
223-
224- func commandPrune () * exec.Cmd {
225- return exec .Command (dockerExe , "system" , "prune" , "-f" )
226- }
227-
228- // helper to check if args match "docker rmi"
229- func isCommandRmi (args []string ) bool {
230- return len (args ) > 2 && args [1 ] == "rmi"
231- }
232-
233- func commandRmi (tag string ) * exec.Cmd {
234- return exec .Command (dockerExe , "rmi" , tag )
235- }
236-
237202// trace writes each command to stdout with the command wrapped in an xml
238203// tag so that it can be extracted and displayed in the logs.
239204func trace (cmd * exec.Cmd ) {
0 commit comments