v1.3.3
Using bzlmod with Bazel 6 or later:
-
Add
common --enable_bzlmod
to.bazelrc
. -
Add to your
MODULE.bazel
file:
bazel_dep(name = "rules_oci", version = "1.3.3")
# For testing, we also recommend https://registry.bazel.build/modules/container_structure_test
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
# Declare external images you need to pull, for example:
oci.pull(
name = "distroless_base",
# 'latest' is not reproducible, but it's convenient.
# During the build we print a WARNING message that includes recommended 'digest' and 'platforms'
# values which you can use here in place of 'tag' to pin for reproducibility.
tag = "latest",
image = "gcr.io/distroless/base",
platforms = ["linux/amd64"],
)
# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "distroless_base")
Using WORKSPACE:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_oci",
sha256 = "72064a9efca8629ec759f207507078bb7f3b7f00de2e5af7438fa12b2f8cd33d",
strip_prefix = "rules_oci-1.3.3",
url = "https://github.com/bazel-contrib/rules_oci/releases/download/v1.3.3/rules_oci-v1.3.3.tar.gz",
)
load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
rules_oci_dependencies()
load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "LATEST_ZOT_VERSION", "oci_register_toolchains")
oci_register_toolchains(
name = "oci",
crane_version = LATEST_CRANE_VERSION,
# Uncommenting the zot toolchain will cause it to be used instead of crane for some tasks.
# Note that it does not support docker-format images.
# zot_version = LATEST_ZOT_VERSION,
)
# You can pull your base images using oci_pull like this:
load("@rules_oci//oci:pull.bzl", "oci_pull")
oci_pull(
name = "distroless_base",
digest = "sha256:ccaef5ee2f1850270d453fdf700a5392534f8d1a8ca2acda391fbb6a06b81c86",
image = "gcr.io/distroless/base",
platforms = [
"linux/amd64",
"linux/arm64",
],
)
What's Changed
- feat: provide the sha256 digest as an oci_image target by @alexeagle in #346
- feat: make cmd and environment attributes stampable by @sfc-gh-ptabor in #297
- fix: propagate tags for macros in
defs.bzl
by @ajaypbrt in #350 - fix: digest output should include algo by @alexeagle in #354
- Allow passing repository for oci_push in from a file by @mboulton-fathom in #338
- fix(pull): reproducible attribute of oci_pull macro was unused. by @alexeagle in #355
- feat: add mnemonic to the oci_image_index action by @lbcjbb in #348
- feat: add Azure Container Registry oci_pull support by @HDYA in #340
- fix: remove tag argument from crane image mutate call by @aaliddell in #352
- example: make sure capital letter targets work by @thesayyn in #356
- Fix invalid tarball manifest creation by @mboulton-fathom in #326
New Contributors
- @ajaypbrt made their first contribution in #350
- @mboulton-fathom made their first contribution in #338
- @lbcjbb made their first contribution in #348
- @HDYA made their first contribution in #340
Full Changelog: v1.3.2...v1.3.3