A repository rule to pull image layers using Bazel's downloader.
Typical usage in WORKSPACE.bazel
:
load("@rules_oci//oci:pull.bzl", "oci_pull")
# A single-arch base image
oci_pull(
name = "distroless_java",
digest = "sha256:161a1d97d592b3f1919801578c3a47c8e932071168a96267698f4b669c24c76d",
image = "gcr.io/distroless/java17",
)
# A multi-arch base image
oci_pull(
name = "distroless_static",
digest = "sha256:c3c3d0230d487c0ad3a0d87ad03ee02ea2ff0b3dcce91ca06a1019e07de05f12",
image = "gcr.io/distroless/static",
platforms = [
"linux/amd64",
"linux/arm64",
],
)
Now you can refer to these as a base layer in BUILD.bazel
.
The target is named the same as the external repo, so you can use a short label syntax:
oci_image(
name = "app",
base = "@distroless_static",
...
)
oci_pull(name, image, repository, registry, platforms, digest, tag, reproducible, is_bzlmod)
Repository macro to fetch image manifest data from a remote docker registry.
To use the resulting image, you can use the @wkspc
shorthand label, for example
if name = "distroless_base"
, then you can just use base = "@distroless_base"
in rules like oci_image
.
This shorthand syntax is broken on the command-line prior to Bazel 6.2. See bazelbuild/bazel#4385
PARAMETERS