Skip to content

Latest commit

 

History

History
106 lines (73 loc) · 3.14 KB

image_index.md

File metadata and controls

106 lines (73 loc) · 3.14 KB

To load these rules, add this to the top of your BUILD file:

load("@rules_oci//oci:defs.bzl", ...)

oci_image_index_rule

oci_image_index_rule(name, images, platforms)

Build a multi-architecture OCI compatible container image.

It takes number of oci_image targets to create a fat multi-architecture image conforming to OCI Image Index Specification.

Image indexes can be created in two ways:

Using Bazel platforms

While this feature is still experimental, it is the recommended way to create image indexes.

go_binary(
    name = "app_can_cross_compile"
)

tar(
    name = "app_layer",
    srcs = [
        ":app_can_cross_compile",
    ],
)

oci_image(
    name = "image",
    tars = [":app_layer"],
)

oci_image_index(
    name = "image_multiarch",
    images = [":image"],
    platforms = [
        "@rules_go//go/toolchain:linux_amd64",
        "@rules_go//go/toolchain:linux_arm64",
    ],
)

Without using Bazel platforms

oci_image(
    name = "app_linux_amd64"
)

oci_image(
    name = "app_linux_arm64"
)

oci_image_index(
    name = "app",
    images = [
        ":app_linux_amd64",
        ":app_linux_arm64"
    ]
)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
images List of labels to oci_image targets. List of labels required
platforms This feature is highly EXPERIMENTAL and not subject to our usual SemVer guarantees. A list of platform targets to build the image for. If specified, only one image can be specified in the images attribute. List of labels optional []

oci_image_index

oci_image_index(name, kwargs)

Macro wrapper around oci_image_index_rule.

Produces a target [name].digest, whose default output is a file containing the sha256 digest of the resulting image. This is the same output as for the oci_image macro.

PARAMETERS

Name Description Default Value
name name of resulting oci_image_index_rule none
kwargs other named arguments to oci_image_index_rule and common rule attributes. none