Skip to content

Commit

Permalink
feat: add generate_empty_layers attribute to js_image_layer
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed May 10, 2024
1 parent 5ea48fb commit 1a85da6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/js_image_layer.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions e2e/js_image_docker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ js_binary(
js_image_layer(
name = "layers",
binary = ":bin",
generate_empty_layers = True,
root = "/app",
visibility = ["//visibility:__pkg__"],
)
Expand All @@ -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"],
Expand Down Expand Up @@ -101,6 +113,7 @@ container_image(
layers = [
":node_layer",
":package_store_3p_layer",
":package_store_1p_layer",
":node_modules_layer",
":app_layer",
],
Expand Down
5 changes: 4 additions & 1 deletion js/private/js_image_layer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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.",
),
},
)

Expand Down

0 comments on commit 1a85da6

Please sign in to comment.