Skip to content

Commit af2b074

Browse files
Enable experimental_tarball_format for container_bundle. (#1938)
Resolves TODO. Seems to improve build time. Co-authored-by: aptenodytes-forsteri <aptenodytesforstericodes@gmail.com>
1 parent debc18a commit af2b074

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

container/bundle.bzl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ def _container_bundle_impl(ctx):
7373
ctx,
7474
images,
7575
ctx.outputs.tar_output,
76-
# Experiment: currently only support experimental_tarball_format in
77-
# container_image for testing optimization.
78-
# TODO(#1695): Update this.
79-
"legacy",
76+
ctx.attr.experimental_tarball_format,
8077
stamp = stamp,
8178
)
8279

@@ -109,6 +106,19 @@ container_bundle_ = rule(
109106
mandatory = False,
110107
),
111108
"tar_output": attr.output(),
109+
"experimental_tarball_format": attr.string(
110+
values = [
111+
"legacy",
112+
"compressed",
113+
],
114+
default = "legacy",
115+
doc = ("The tarball format to use when producing an image .tar file. " +
116+
"Defaults to \"legacy\", which contains uncompressed layers. " +
117+
"If set to \"compressed\", the resulting tarball will contain " +
118+
"compressed layers, but is only loadable by newer versions of " +
119+
"docker. This is an experimental attribute, which is subject " +
120+
"to change or removal: do not depend on its exact behavior."),
121+
),
112122
}, _layer_tools),
113123
executable = True,
114124
toolchains = ["@io_bazel_rules_docker//toolchains/docker:toolchain_type"],

docs/container.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Load these from `@io_bazel_rules_docker//container:container.bzl`.
88
## container_bundle
99

1010
<pre>
11-
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>,
12-
<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>)
11+
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>,
12+
<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>)
1313
</pre>
1414

1515
A rule that aliases and saves N images into a single `docker save` tarball.
@@ -20,6 +20,7 @@ A rule that aliases and saves N images into a single `docker save` tarball.
2020
| Name | Description | Type | Mandatory | Default |
2121
| :------------- | :------------- | :------------- | :------------- | :------------- |
2222
| <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 | |
23+
| <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" |
2324
| <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 |
2425
| <a id="container_bundle-image_target_strings"></a>image_target_strings | - | List of strings | optional | [] |
2526
| <a id="container_bundle-image_targets"></a>image_targets | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |

tests/container/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ container_image(
988988
# would take substantially longer for this target.
989989
container_bundle(
990990
name = "container_bundle_with_install_pkgs",
991+
experimental_tarball_format = "compressed",
991992
images = {
992993
"install_pkgs_1:latest": ":test_install_pkgs",
993994
"install_pkgs_2:latest": ":test_install_git_for_reproducibility_1",

0 commit comments

Comments
 (0)