From 0e2b2789cbaa0999947c152595c0b6358be3454c Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 10 May 2024 11:00:08 -0700 Subject: [PATCH] feat: add generate_empty_layers attribute to js_image_layer --- e2e/js_image_docker/BUILD.bazel | 13 +++++++++++++ js/private/js_image_layer.bzl | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/e2e/js_image_docker/BUILD.bazel b/e2e/js_image_docker/BUILD.bazel index fafc5d8f42..4e242a6aa6 100644 --- a/e2e/js_image_docker/BUILD.bazel +++ b/e2e/js_image_docker/BUILD.bazel @@ -43,6 +43,7 @@ js_image_layer( name = "layers", binary = ":bin", root = "/app", + # generate_empty_layers = True, visibility = ["//visibility:__pkg__"], ) @@ -68,6 +69,17 @@ container_layer( tars = [":package_store_3p_tar"], ) +filegroup( + name = "package_store_1p_tar", + srcs = [":layers"], + output_group = "package_store_1p", +) + +container_layer( + name = "package_store_1p_layer", + tars = [":package_store_1p_tar"], +) + filegroup( name = "node_modules_tar", srcs = [":layers"], @@ -101,6 +113,7 @@ container_image( layers = [ ":node_layer", ":package_store_3p_layer", + ":package_store_1p_layer", ":node_modules_layer", ":app_layer", ], diff --git a/js/private/js_image_layer.bzl b/js/private/js_image_layer.bzl index 8a3e11f16e..327cce1a31 100644 --- a/js/private/js_image_layer.bzl +++ b/js/private/js_image_layer.bzl @@ -279,7 +279,7 @@ def _runfile_path(ctx, file, runfiles_dir): return paths.join(runfiles_dir, to_rlocation_path(ctx, file)) def _build_layer(ctx, type, all_entries_json, entries, inputs): - if not entries: + if not entries and not ctx.attr.generate_empty_layers: return None entries_json = ctx.actions.declare_file("{}_{}_entries.json".format(ctx.label.name, type)) @@ -490,6 +490,9 @@ js_image_layer_lib = struct( "platform": attr.label( doc = "Platform to transition.", ), + "generate_empty_layers": attr.bool( + doc = "Generate layers even if they are empty.", + ), }, )