@@ -684,7 +684,8 @@ func maybeSkipArchive(env build.Environment) {
684
684
func doDockerBuildx (cmdline []string ) {
685
685
var (
686
686
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` )
688
689
)
689
690
flag .CommandLine .Parse (cmdline )
690
691
@@ -719,25 +720,33 @@ func doDockerBuildx(cmdline []string) {
719
720
tags = []string {"stable" , fmt .Sprintf ("release-%v" , version .Family ), "v" + version .Semantic }
720
721
}
721
722
// 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
+ }
723
727
724
728
for _ , spec := range []struct {
725
729
file string
726
730
base string
727
731
}{
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 )},
730
734
} {
731
735
for _ , tag := range tags { // latest, stable etc
732
736
gethImage := fmt .Sprintf ("%s%s" , spec .base , tag )
733
- build . MustRunCommand ("docker" , "buildx" , "build" ,
737
+ cmd := exec . Command ("docker" , "buildx" , "build" ,
734
738
"--build-arg" , "COMMIT=" + env .Commit ,
735
739
"--build-arg" , "VERSION=" + version .WithMeta ,
736
740
"--build-arg" , "BUILDNUM=" + env .Buildnum ,
737
741
"--tag" , gethImage ,
738
742
"--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 )
741
750
}
742
751
}
743
752
}
0 commit comments