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.
This commit is contained in:
parent
fa9a2ff868
commit
b3833e5d98
|
@ -25,7 +25,7 @@ jobs:
|
||||||
before_install:
|
before_install:
|
||||||
- export DOCKER_CLI_EXPERIMENTAL=enabled
|
- export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
script:
|
script:
|
||||||
- go run build/ci.go dockerx -platform "linux/amd64,linux/arm64,linux/riscv64" -upload ethereum/client-go
|
- go run build/ci.go dockerx -platform "linux/amd64,linux/arm64,linux/riscv64" -hub ethereum/client-go -upload
|
||||||
|
|
||||||
# This builder does the Linux Azure uploads
|
# This builder does the Linux Azure uploads
|
||||||
- stage: build
|
- stage: build
|
||||||
|
|
21
build/ci.go
21
build/ci.go
|
@ -684,7 +684,8 @@ func maybeSkipArchive(env build.Environment) {
|
||||||
func doDockerBuildx(cmdline []string) {
|
func doDockerBuildx(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
platform = flag.String("platform", "", `Push a multi-arch docker image for the specified architectures (usually "linux/amd64,linux/arm64")`)
|
platform = flag.String("platform", "", `Push a multi-arch docker image for the specified architectures (usually "linux/amd64,linux/arm64")`)
|
||||||
upload = flag.String("upload", "", `Where to upload the docker image (usually "ethereum/client-go")`)
|
hubImage = flag.String("hub", "ethereum/client-go", `Where to upload the docker image`)
|
||||||
|
upload = flag.Bool("upload", false, `Whether to trigger upload`)
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
|
|
||||||
|
@ -719,25 +720,33 @@ func doDockerBuildx(cmdline []string) {
|
||||||
tags = []string{"stable", fmt.Sprintf("release-%v", version.Family), "v" + version.Semantic}
|
tags = []string{"stable", fmt.Sprintf("release-%v", version.Family), "v" + version.Semantic}
|
||||||
}
|
}
|
||||||
// Need to create a mult-arch builder
|
// Need to create a mult-arch builder
|
||||||
|
check := exec.Command("docker", "buildx", "inspect", "multi-arch-builder")
|
||||||
|
if check.Run() != nil {
|
||||||
build.MustRunCommand("docker", "buildx", "create", "--use", "--name", "multi-arch-builder", "--platform", *platform)
|
build.MustRunCommand("docker", "buildx", "create", "--use", "--name", "multi-arch-builder", "--platform", *platform)
|
||||||
|
}
|
||||||
|
|
||||||
for _, spec := range []struct {
|
for _, spec := range []struct {
|
||||||
file string
|
file string
|
||||||
base string
|
base string
|
||||||
}{
|
}{
|
||||||
{file: "Dockerfile", base: fmt.Sprintf("%s:", *upload)},
|
{file: "Dockerfile", base: fmt.Sprintf("%s:", *hubImage)},
|
||||||
{file: "Dockerfile.alltools", base: fmt.Sprintf("%s:alltools-", *upload)},
|
{file: "Dockerfile.alltools", base: fmt.Sprintf("%s:alltools-", *hubImage)},
|
||||||
} {
|
} {
|
||||||
for _, tag := range tags { // latest, stable etc
|
for _, tag := range tags { // latest, stable etc
|
||||||
gethImage := fmt.Sprintf("%s%s", spec.base, tag)
|
gethImage := fmt.Sprintf("%s%s", spec.base, tag)
|
||||||
build.MustRunCommand("docker", "buildx", "build",
|
cmd := exec.Command("docker", "buildx", "build",
|
||||||
"--build-arg", "COMMIT="+env.Commit,
|
"--build-arg", "COMMIT="+env.Commit,
|
||||||
"--build-arg", "VERSION="+version.WithMeta,
|
"--build-arg", "VERSION="+version.WithMeta,
|
||||||
"--build-arg", "BUILDNUM="+env.Buildnum,
|
"--build-arg", "BUILDNUM="+env.Buildnum,
|
||||||
"--tag", gethImage,
|
"--tag", gethImage,
|
||||||
"--platform", *platform,
|
"--platform", *platform,
|
||||||
"--push",
|
"--file", spec.file,
|
||||||
"--file", spec.file, ".")
|
)
|
||||||
|
if *upload {
|
||||||
|
cmd.Args = append(cmd.Args, "--push")
|
||||||
|
}
|
||||||
|
cmd.Args = append(cmd.Args, ".")
|
||||||
|
build.MustRun(cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue