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 = "2.2.0")
# 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 = "1bd16e455278d523f01326e0c3964cd64d7840a7e99cdd6e2617e59f698f3504",
strip_prefix = "rules_oci-2.2.0",
url = "https://github.com/bazel-contrib/rules_oci/releases/download/v2.2.0/rules_oci-v2.2.0.tar.gz",
)
load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
rules_oci_dependencies()
load("@rules_oci//oci:repositories.bzl", "oci_register_toolchains")
oci_register_toolchains(name = "oci")
# 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
- use compression in examples by @pdeva in #718
- Add a plus sign to the output_groups option by @lexspoon in #707
- refactor: remote_tags unnecessarily restrictive by @thesayyn in #726
- Update scala.md: oci_tarball was renamed by @alexeagle in #728
- doc: cover the inline-specified variants of arguments to oci_image by @plobsing in #705
- fix: pass global args to all crane invocations by @ahans in #709
- Introduce new attribute on
oci_image
forcreated
datetime by @hanneskaeufler in #724 - Fix macOS CI after #724 by @hanneskaeufler in #730
- feat: Possible to skip cosign toolchains registration by @honnix in #733
- chore: upgrade regctl by @alexeagle in #744
- chore(cd): automate release tagging by @alexeagle in #745
- chore(ci): disable two failing tests by @alexeagle in #747
- chore: fix tag name when called by workflow by @alexeagle in #749
- feat: Transition oci_image_index into a macro with additional [name].digest target by @mislavmandaricaxilis in #742
New Contributors
- @pdeva made their first contribution in #718
- @lexspoon made their first contribution in #707
- @ahans made their first contribution in #709
- @hanneskaeufler made their first contribution in #724
- @honnix made their first contribution in #733
- @mislavmandaricaxilis made their first contribution in #742
Full Changelog: v2.0.1...v2.2.0