Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 2.96 KB

load.md

File metadata and controls

72 lines (49 loc) · 2.96 KB

Load an oci_image into runtimes such as podman and docker. Intended for use with bazel run.

For example, given an :image target, you could write

oci_load(
    name = "load",
    image = ":image",
    repo_tags = ["my-repository:latest"],
)

and then run it in a container like so:

bazel run :load
docker run --rm my-repository:latest

oci_load

oci_load(name, format, image, loader, repo_tags)

Loads an OCI layout into a container daemon without needing to publish the image first.

Passing anything other than oci_image to the image attribute will lead to build time errors.

Build Outputs

The default output is an mtree specification file. This is because producing the tarball in bazel build is expensive, and should typically not be an input to any other build actions, so producing it only creates unnecessary load on the action cache.

If needed, the tarball output group allows you to depend on the tar output from another rule.

On the command line, bazel build //path/to:my_tarball --output_groups=tarball

or in a BUILD file:

oci_load(
    name = "my_tarball",
    ...
)
filegroup(
    name = "my_tarball.tar",
    srcs = [":my_tarball"],
    output_group = "tarball",
)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
format Format of image to generate. Options are: docker, oci. Currently, when the input image is an image_index, only oci is supported, and when the input image is an image, only docker is supported. Conversions between formats may be supported in the future. String optional "docker"
image Label of a directory containing an OCI layout, typically oci_image Label required
loader Alternative target for a container cli tool that will be used to load the image into the local engine when using bazel run on this target.

By default, we look for docker or podman on the PATH, and run the load command.

See the _run_template attribute for the script that calls this loader tool.
Label optional None
repo_tags a file containing repo_tags, one per line. Label required