@@ -684,7 +684,8 @@ func maybeSkipArchive(env build.Environment) {
684684func doDockerBuildx (cmdline []string ) {
685685 var (
686686 platform = flag .String ("platform" , "" , `Push a multi-arch docker image for the specified architectures (usually "linux/amd64,linux/arm64")` )
687- upload = flag .String ("upload" , "" , `Where to upload the docker image (usually "ethereum/client-go")` )
687+ hubImage = flag .String ("hub" , "ethereum/client-go" , `Where to upload the docker image` )
688+ upload = flag .Bool ("upload" , false , `Whether to trigger upload` )
688689 )
689690 flag .CommandLine .Parse (cmdline )
690691
@@ -719,25 +720,33 @@ func doDockerBuildx(cmdline []string) {
719720 tags = []string {"stable" , fmt .Sprintf ("release-%v" , version .Family ), "v" + version .Semantic }
720721 }
721722 // Need to create a mult-arch builder
722- build .MustRunCommand ("docker" , "buildx" , "create" , "--use" , "--name" , "multi-arch-builder" , "--platform" , * platform )
723+ check := exec .Command ("docker" , "buildx" , "inspect" , "multi-arch-builder" )
724+ if check .Run () != nil {
725+ build .MustRunCommand ("docker" , "buildx" , "create" , "--use" , "--name" , "multi-arch-builder" , "--platform" , * platform )
726+ }
723727
724728 for _ , spec := range []struct {
725729 file string
726730 base string
727731 }{
728- {file : "Dockerfile" , base : fmt .Sprintf ("%s:" , * upload )},
729- {file : "Dockerfile.alltools" , base : fmt .Sprintf ("%s:alltools-" , * upload )},
732+ {file : "Dockerfile" , base : fmt .Sprintf ("%s:" , * hubImage )},
733+ {file : "Dockerfile.alltools" , base : fmt .Sprintf ("%s:alltools-" , * hubImage )},
730734 } {
731735 for _ , tag := range tags { // latest, stable etc
732736 gethImage := fmt .Sprintf ("%s%s" , spec .base , tag )
733- build . MustRunCommand ("docker" , "buildx" , "build" ,
737+ cmd := exec . Command ("docker" , "buildx" , "build" ,
734738 "--build-arg" , "COMMIT=" + env .Commit ,
735739 "--build-arg" , "VERSION=" + version .WithMeta ,
736740 "--build-arg" , "BUILDNUM=" + env .Buildnum ,
737741 "--tag" , gethImage ,
738742 "--platform" , * platform ,
739- "--push" ,
740- "--file" , spec .file , "." )
743+ "--file" , spec .file ,
744+ )
745+ if * upload {
746+ cmd .Args = append (cmd .Args , "--push" )
747+ }
748+ cmd .Args = append (cmd .Args , "." )
749+ build .MustRun (cmd )
741750 }
742751 }
743752}
0 commit comments