Less verbose, no docker commands

This commit is contained in:
Michael Chen 2022-11-15 09:46:03 +01:00
parent a8a32e91b9
commit 099436306b
Signed by: cnml
GPG Key ID: 5845BF3F82D5F629

View File

@ -134,7 +134,7 @@ def download_file(file: DownloadInfo, filename: Path):
return filename
def docker_buildx(repository: str, tags: list[str], build_platforms: list[DockerPlatforms], dockerfile: str = "Dockerfile", build_args: DockerfileBuildArgs | dict[str, Any] | None = None, directory: str = "."):
def docker_buildx(repository: str, tags: list[str], build_platforms: list[DockerPlatforms], dockerfile: str = "Dockerfile", build_args: DockerfileBuildArgs | dict[str, Any] | None = None, directory: str = ".", write_command: bool = False):
if build_args is None:
build_args = dict()
labels = [f"{repository}:{tag}"for tag in tags]
@ -145,8 +145,10 @@ def docker_buildx(repository: str, tags: list[str], build_platforms: list[Docker
"--file", dockerfile,
*[t for label in labels for t in ("--tag", label)],
"--pull", "--push", directory]
if write_command:
print(" ".join(command))
process = subprocess.run(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
process = subprocess.run(
command, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
if process.returncode != 0:
output = process.stdout.decode('utf-8')
print(output)
@ -190,7 +192,7 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
print(
f"Building version {version['id']} (Java {java_version['majorVersion']})")
# Build GraalVM images
print("# Build GraalVM images")
if java_version['majorVersion'] == 17:
graal_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
build_args["DOCKER_IMAGE"] = f"ghcr.io/graalvm/jdk:java{java_version['majorVersion']}"
@ -200,7 +202,7 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
print(
f"No GraalVM image can be built for {version['id']} (Java {java_version['majorVersion']})")
# Build Temurin
print("# Build Temurin images")
build_args["DOCKER_IMAGE"] = f"eclipse-temurin:{java_version['majorVersion']}-jre"
temurin_platforms: list[DockerPlatforms] = [
"linux/arm64", "linux/arm/v7", "linux/amd64", "linux/ppc64le"]