From c753e4c6af3cd5757cab3e4a2a11465043dd8633 Mon Sep 17 00:00:00 2001 From: Appu Date: Wed, 13 May 2026 13:13:30 -0400 Subject: [PATCH] refactor nodejs build code Signed-off-by: Appu --- nodejs/BUILD | 3 ++- nodejs/config.bzl | 8 ++++++++ nodejs/nodejs.bzl | 14 ++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/nodejs/BUILD b/nodejs/BUILD index f2e125c9c..92494508f 100644 --- a/nodejs/BUILD +++ b/nodejs/BUILD @@ -1,4 +1,4 @@ -load(":config.bzl", "NODEJS_ARCHITECTURES", "NODEJS_DISTROS", "NODEJS_MAJOR_VERSIONS") +load(":config.bzl", "NODEJS_ARCHITECTURES", "NODEJS_DISTROS", "NODEJS_MAJOR_VERSIONS", "NODEJS_PACKAGES") load(":nodejs.bzl", "nodejs_image", "nodejs_image_index") package(default_visibility = ["//visibility:public"]) @@ -8,6 +8,7 @@ package(default_visibility = ["//visibility:public"]) arch = arch, distro = distro, major_version = major_version, + packages = NODEJS_PACKAGES[major_version], ) for distro in NODEJS_DISTROS for major_version in NODEJS_MAJOR_VERSIONS diff --git a/nodejs/config.bzl b/nodejs/config.bzl index 6bad91993..f7c4b0e7d 100644 --- a/nodejs/config.bzl +++ b/nodejs/config.bzl @@ -7,3 +7,11 @@ NODEJS_ARCHITECTURES = { }, } NODEJS_MAJOR_VERSIONS = ["22", "24", "26"] + +NODEJS_PACKAGES = { + "22": [], + "24": [], + "26": [ + "libatomic1", + ], +} diff --git a/nodejs/nodejs.bzl b/nodejs/nodejs.bzl index 24515e729..faeb92e6e 100644 --- a/nodejs/nodejs.bzl +++ b/nodejs/nodejs.bzl @@ -35,21 +35,16 @@ def _check_certificates_tar(): srcs = ["testdata/check_certificate.js"], ) -def nodejs_image(distro, major_version, arch): +def nodejs_image(distro, major_version, arch, packages): """nodejs and debug image with tests. Args: distro: name of distribution major_version: version of nodejs arch: the target arch + packages: any deb packages to add to the image """ - # node 26 and later dynamically link libatomic.so.1, which isn't in the cc base image. - # Layer libatomic1 onto the nodejs26+ images only so we don't bloat other images. - extra_tars = [] - if int(major_version) >= 26: - extra_tars = [deb.package(arch, distro, "libatomic1")] - for mode in DEBUG_MODE: for user in USERS: oci_image( @@ -57,8 +52,11 @@ def nodejs_image(distro, major_version, arch): base = "//cc:cc" + mode + "_" + user + "_" + arch + "_" + distro, entrypoint = ["/nodejs/bin/node"], tars = [ + deb.package(arch, distro, pkg) + for pkg in packages + ] + [ "@nodejs" + major_version + "_" + arch, - ] + extra_tars, + ], ) _check_certificates_tar()