@@ -689,7 +689,8 @@ func maybeSkipArchive(env build.Environment) {
689689func doDockerBuildx (cmdline []string ) {
690690 var (
691691 platform = flag .String ("platform" , "" , `Push a multi-arch docker image for the specified architectures (usually "linux/amd64,linux/arm64")` )
692- upload = flag .String ("upload" , "" , `Where to upload the docker image (usually "ethereum/client-go")` )
692+ hubImage = flag .String ("hub" , "ethereum/client-go" , `Where to upload the docker image` )
693+ upload = flag .Bool ("upload" , false , `Whether to trigger upload` )
693694 )
694695 flag .CommandLine .Parse (cmdline )
695696
@@ -724,25 +725,33 @@ func doDockerBuildx(cmdline []string) {
724725 tags = []string {"stable" , fmt .Sprintf ("release-%v" , version .Family ), "v" + version .Semantic }
725726 }
726727 // Need to create a mult-arch builder
727- build .MustRunCommand ("docker" , "buildx" , "create" , "--use" , "--name" , "multi-arch-builder" , "--platform" , * platform )
728+ check := exec .Command ("docker" , "buildx" , "inspect" , "multi-arch-builder" )
729+ if check .Run () != nil {
730+ build .MustRunCommand ("docker" , "buildx" , "create" , "--use" , "--name" , "multi-arch-builder" , "--platform" , * platform )
731+ }
728732
729733 for _ , spec := range []struct {
730734 file string
731735 base string
732736 }{
733- {file : "Dockerfile" , base : fmt .Sprintf ("%s:" , * upload )},
734- {file : "Dockerfile.alltools" , base : fmt .Sprintf ("%s:alltools-" , * upload )},
737+ {file : "Dockerfile" , base : fmt .Sprintf ("%s:" , * hubImage )},
738+ {file : "Dockerfile.alltools" , base : fmt .Sprintf ("%s:alltools-" , * hubImage )},
735739 } {
736740 for _ , tag := range tags { // latest, stable etc
737741 gethImage := fmt .Sprintf ("%s%s" , spec .base , tag )
738- build . MustRunCommand ("docker" , "buildx" , "build" ,
742+ cmd := exec . Command ("docker" , "buildx" , "build" ,
739743 "--build-arg" , "COMMIT=" + env .Commit ,
740744 "--build-arg" , "VERSION=" + version .WithMeta ,
741745 "--build-arg" , "BUILDNUM=" + env .Buildnum ,
742746 "--tag" , gethImage ,
743747 "--platform" , * platform ,
744- "--push" ,
745- "--file" , spec .file , "." )
748+ "--file" , spec .file ,
749+ )
750+ if * upload {
751+ cmd .Args = append (cmd .Args , "--push" )
752+ }
753+ cmd .Args = append (cmd .Args , "." )
754+ build .MustRun (cmd )
746755 }
747756 }
748757}
0 commit comments