Skip to content

Commit 98ab00a

Browse files
fjlqianhh
authored andcommitted
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 feb6b99 commit 98ab00a

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
@@ -689,7 +689,8 @@ func maybeSkipArchive(env build.Environment) {
689689
func 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

Comments
 (0)