Skip to content

Commit b3833e5

Browse files
authored
build: provide a flag to disable publishing in dockerx build (#31098)
This changes the `-upload` flag to just toggle the upload. The remote image name is now configured using the `-hub` flag.
1 parent fa9a2ff commit b3833e5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
before_install:
2626
- export DOCKER_CLI_EXPERIMENTAL=enabled
2727
script:
28-
- go run build/ci.go dockerx -platform "linux/amd64,linux/arm64,linux/riscv64" -upload ethereum/client-go
28+
- go run build/ci.go dockerx -platform "linux/amd64,linux/arm64,linux/riscv64" -hub ethereum/client-go -upload
2929

3030
# This builder does the Linux Azure uploads
3131
- stage: build

build/ci.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,8 @@ func maybeSkipArchive(env build.Environment) {
684684
func 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

Comments
 (0)