From ed91f784bfbd0c53642a7d1eccb701816dfbd0bf Mon Sep 17 00:00:00 2001 From: Javier Maestro Date: Sun, 1 Sep 2024 15:34:07 +0100 Subject: [PATCH] Add Blzmod example to pull.md (#671) --- docs/pull.md | 42 +++++++++++++++++++++++++++++++++++++++++- oci/pull.bzl | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/docs/pull.md b/docs/pull.md index 33676837..4c8a80df 100644 --- a/docs/pull.md +++ b/docs/pull.md @@ -25,17 +25,57 @@ oci_pull( "linux/arm64", ], ) + +# A multi-arch base image with variants, note that it won't work with just "linux/arm64" +oci_pull( + name = "distroless_base_nossl_debian12", + digest = "sha256:73c3d3f3030516665c916ebc9baa80f89c1a90e438dc02f1fed525ed246c0c2a", + image = "gcr.io/distroless/base-nossl-debian12", + platforms = [ + "linux/amd64", + "linux/arm64/v8", + ], +) +``` + +Typical usage in `MODULE.bazel`: + +```starlark +oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") + +# A multi-arch base image with variants, note that it won't work with just "linux/arm64" +oci.pull( + name = "distroless_base_nossl_debian12", + digest = "sha256:73c3d3f3030516665c916ebc9baa80f89c1a90e438dc02f1fed525ed246c0c2a", + image = "gcr.io/distroless/base-nossl-debian12", + platforms = [ + "linux/amd64", + "linux/arm64/v8", + ], +) +use_repo( + oci, + "distroless_base_nossl_debian12", + "distroless_base_nossl_debian12_linux_amd64", + "distroless_base_nossl_debian12_linux_arm64_v8", +) ``` 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: -``` +```starlark oci_image( name = "app", base = "@distroless_static", ... ) + +oci_image( + name = "app_arm64_v8", + base = "@distroless_base_nossl_debian12_linux_arm64_v8", + ... +) ``` ## Configuration diff --git a/oci/pull.bzl b/oci/pull.bzl index 8a1093dc..147791c8 100644 --- a/oci/pull.bzl +++ b/oci/pull.bzl @@ -23,17 +23,57 @@ oci_pull( "linux/arm64", ], ) + +# A multi-arch base image with variants, note that it won't work with just "linux/arm64" +oci_pull( + name = "distroless_base_nossl_debian12", + digest = "sha256:73c3d3f3030516665c916ebc9baa80f89c1a90e438dc02f1fed525ed246c0c2a", + image = "gcr.io/distroless/base-nossl-debian12", + platforms = [ + "linux/amd64", + "linux/arm64/v8", + ], +) +``` + +Typical usage in `MODULE.bazel`: + +```starlark +oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") + +# A multi-arch base image with variants, note that it won't work with just "linux/arm64" +oci.pull( + name = "distroless_base_nossl_debian12", + digest = "sha256:73c3d3f3030516665c916ebc9baa80f89c1a90e438dc02f1fed525ed246c0c2a", + image = "gcr.io/distroless/base-nossl-debian12", + platforms = [ + "linux/amd64", + "linux/arm64/v8", + ], +) +use_repo( + oci, + "distroless_base_nossl_debian12", + "distroless_base_nossl_debian12_linux_amd64", + "distroless_base_nossl_debian12_linux_arm64_v8", +) ``` 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: -``` +```starlark oci_image( name = "app", base = "@distroless_static", ... ) + +oci_image( + name = "app_arm64_v8", + base = "@distroless_base_nossl_debian12_linux_arm64_v8", + ... +) ``` ## Configuration