From 150c932c034ead8988c74244247d9245fcc15e1d Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 27 Mar 2024 12:15:29 +0100 Subject: [PATCH] Build ARM64 bb_runner_installer images --- WORKSPACE | 14 ++++++++-- cmd/bb_runner/BUILD.bazel | 59 +++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 70a172a1..580ab399 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -99,7 +99,7 @@ oci_pull( oci_pull( name = "busybox", - digest = "sha256:a2490cec4484ee6c1068ba3a05f89934010c85242f736280b35343483b2264b6", # 1.31.1-uclibc + digest = "sha256:97e3873d1f61ba651b632e4755fc52e1d90c9f6e4f01d9b720f37af5efed17e5", # 1.36.1-uclibc image = "docker.io/library/busybox", platforms = [ "linux/amd64", @@ -144,8 +144,16 @@ http_file( name = "com_github_krallin_tini_tini_static_amd64", downloaded_file_path = "tini", executable = True, - sha256 = "eadb9d6e2dc960655481d78a92d2c8bc021861045987ccd3e27c7eae5af0cf33", - urls = ["https://github.com/krallin/tini/releases/download/v0.18.0/tini-static-amd64"], + sha256 = "c5b0666b4cb676901f90dfcb37106783c5fe2077b04590973b885950611b30ee", + urls = ["https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-amd64"], +) + +http_file( + name = "com_github_krallin_tini_tini_static_arm64", + downloaded_file_path = "tini", + executable = True, + sha256 = "eae1d3aa50c48fb23b8cbdf4e369d0910dfc538566bfd09df89a774aa84a48b9", + urls = ["https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-arm64"], ) http_archive( diff --git a/cmd/bb_runner/BUILD.bazel b/cmd/bb_runner/BUILD.bazel index fb5fba91..e590c173 100644 --- a/cmd/bb_runner/BUILD.bazel +++ b/cmd/bb_runner/BUILD.bazel @@ -1,6 +1,7 @@ +load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image") load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") -load("@rules_oci//oci:defs.bzl", "oci_image") +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_image_index") load("@rules_pkg//pkg:tar.bzl", "pkg_tar") go_library( @@ -35,6 +36,17 @@ go_binary( visibility = ["//visibility:public"], ) +multiarch_go_image( + name = "bb_runner_bare_container", + binary = ":bb_runner", +) + +container_push_official( + name = "bb_runner_bare_container_push", + component = "bb-runner-bare", + image = ":bb_runner_bare_container", +) + pkg_tar( name = "bb_runner_layer", files = [":bb_runner"], @@ -43,7 +55,15 @@ pkg_tar( pkg_tar( name = "tini_layer", - files = ["@com_github_krallin_tini_tini_static_amd64//file"], + files = select({ + "@io_bazel_rules_go//go/platform:amd64": [ + "@com_github_krallin_tini_tini_static_amd64//file", + ], + "@io_bazel_rules_go//go/platform:arm64": [ + "@com_github_krallin_tini_tini_static_arm64//file", + ], + }), + tags = ["manual"], ) pkg_tar( @@ -51,33 +71,44 @@ pkg_tar( files = ["install"], ) -# TODO: Provide a multi-arch image for bb_runner_installer. oci_image( - name = "bb_runner_installer", + name = "bb_runner_installer_image", base = "@busybox", cmd = ["/bb"], entrypoint = ["/install"], + tags = ["manual"], tars = [ ":install_layer", ":bb_runner_layer", ":tini_layer", ], - visibility = ["//visibility:public"], ) -multiarch_go_image( - name = "bb_runner_bare_container", - binary = ":bb_runner", -) +[ + platform_transition_filegroup( + name = "bb_runner_installer_image_" + arch, + srcs = ["bb_runner_installer_image"], + target_platform = "@io_bazel_rules_go//go/toolchain:linux_" + arch, + ) + for arch in [ + "amd64", + "arm64", + ] +] -container_push_official( - name = "bb_runner_bare_container_push", - component = "bb-runner-bare", - image = ":bb_runner_bare_container", +oci_image_index( + name = "bb_runner_installer_container", + images = [ + "bb_runner_installer_image_" + arch + for arch in [ + "amd64", + "arm64", + ] + ], ) container_push_official( name = "bb_runner_installer_container_push", component = "bb-runner-installer", - image = ":bb_runner_installer", + image = ":bb_runner_installer_container", )