Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Enable experimental_tarball_format for container_bundle. (#1938)
Browse files Browse the repository at this point in the history
Resolves TODO. Seems to improve build time.

Co-authored-by: aptenodytes-forsteri <aptenodytesforstericodes@gmail.com>
  • Loading branch information
aptenodytes-forsteri and aptenodytes-forsteri committed Oct 11, 2021
1 parent debc18a commit af2b074
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
18 changes: 14 additions & 4 deletions container/bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ def _container_bundle_impl(ctx):
ctx,
images,
ctx.outputs.tar_output,
# Experiment: currently only support experimental_tarball_format in
# container_image for testing optimization.
# TODO(#1695): Update this.
"legacy",
ctx.attr.experimental_tarball_format,
stamp = stamp,
)

Expand Down Expand Up @@ -109,6 +106,19 @@ container_bundle_ = rule(
mandatory = False,
),
"tar_output": attr.output(),
"experimental_tarball_format": attr.string(
values = [
"legacy",
"compressed",
],
default = "legacy",
doc = ("The tarball format to use when producing an image .tar file. " +
"Defaults to \"legacy\", which contains uncompressed layers. " +
"If set to \"compressed\", the resulting tarball will contain " +
"compressed layers, but is only loadable by newer versions of " +
"docker. This is an experimental attribute, which is subject " +
"to change or removal: do not depend on its exact behavior."),
),
}, _layer_tools),
executable = True,
toolchains = ["@io_bazel_rules_docker//toolchains/docker:toolchain_type"],
Expand Down
5 changes: 3 additions & 2 deletions docs/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Load these from `@io_bazel_rules_docker//container:container.bzl`.
## container_bundle

<pre>
container_bundle(<a href="#container_bundle-name">name</a>, <a href="#container_bundle-extract_config">extract_config</a>, <a href="#container_bundle-image_target_strings">image_target_strings</a>, <a href="#container_bundle-image_targets">image_targets</a>, <a href="#container_bundle-images">images</a>,
<a href="#container_bundle-incremental_load_template">incremental_load_template</a>, <a href="#container_bundle-stamp">stamp</a>, <a href="#container_bundle-tar_output">tar_output</a>)
container_bundle(<a href="#container_bundle-name">name</a>, <a href="#container_bundle-experimental_tarball_format">experimental_tarball_format</a>, <a href="#container_bundle-extract_config">extract_config</a>, <a href="#container_bundle-image_target_strings">image_target_strings</a>,
<a href="#container_bundle-image_targets">image_targets</a>, <a href="#container_bundle-images">images</a>, <a href="#container_bundle-incremental_load_template">incremental_load_template</a>, <a href="#container_bundle-stamp">stamp</a>, <a href="#container_bundle-tar_output">tar_output</a>)
</pre>

A rule that aliases and saves N images into a single `docker save` tarball.
Expand All @@ -20,6 +20,7 @@ A rule that aliases and saves N images into a single `docker save` tarball.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="container_bundle-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="container_bundle-experimental_tarball_format"></a>experimental_tarball_format | The tarball format to use when producing an image .tar file. Defaults to "legacy", which contains uncompressed layers. If set to "compressed", the resulting tarball will contain compressed layers, but is only loadable by newer versions of docker. This is an experimental attribute, which is subject to change or removal: do not depend on its exact behavior. | String | optional | "legacy" |
| <a id="container_bundle-extract_config"></a>extract_config | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //container/go/cmd/extract_config:extract_config |
| <a id="container_bundle-image_target_strings"></a>image_target_strings | - | List of strings | optional | [] |
| <a id="container_bundle-image_targets"></a>image_targets | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
Expand Down
1 change: 1 addition & 0 deletions tests/container/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ container_image(
# would take substantially longer for this target.
container_bundle(
name = "container_bundle_with_install_pkgs",
experimental_tarball_format = "compressed",
images = {
"install_pkgs_1:latest": ":test_install_pkgs",
"install_pkgs_2:latest": ":test_install_git_for_reproducibility_1",
Expand Down

0 comments on commit af2b074

Please sign in to comment.