A set of rules to operate on container images, such as extracting files or directories from a container image and making them available to Bazel actions.
Add to your MODULE.bazel:
bazel_dep(name = "rules_containers_util", version = "0.0.1")Note
Until a new release of rules_img containing flatten-image is published to the Bazel Central Registry (BCR), configure the rules_img pre-release registry in your .bazelrc:
common --registry=https://bazel-contrib.github.io/rules_img --registry=https://bcr.bazel.build
load("@rules_containers_util//containers:defs.bzl", "image_extract")
# Extract a single file
image_extract(
name = "extracted_tool",
file = "/usr/local/bin/tool",
image = ":my_image",
)
# Extract a directory
image_extract(
name = "extracted_data",
directory = "/opt/data",
image = ":my_image",
)
# Extract multiple files
image_extract(
name = "extracted_files",
files = {
"/etc/app/config.txt": "config.txt",
"/usr/local/bin/helper": "helper",
},
image = ":my_image",
)