Create a tarball from oci_image that can be loaded by runtimes such as podman and docker.
Intended for use with bazel run
.
For example, given an :image
target, you could write
oci_tarball(
name = "tarball",
image = ":image",
repo_tags = ["my-repository:latest"],
)
and then run it in a container like so:
bazel run :tarball
docker run --rm my-repository:latest
oci_tarball(name, format, image, loader, repo_tags)
Creates tarball from OCI layouts that can be loaded into docker daemon without needing to publish the image first.
Passing anything other than oci_image to the image attribute will lead to build time errors.
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_tarball(
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 oci_tarball.By default, we look for docker or podman on the PATH, and run the load command.> Note that rules_docker has an "incremental loader" which is faster than oci_tarball by design. > Something similar can be done for oci_tarball. > See loader.sh and explanation about how it works. 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 |