From af2b074cc8f488e0dcec6230c63c2a7c34cf3dff Mon Sep 17 00:00:00 2001 From: aptenodytes-forsteri <92043606+aptenodytes-forsteri@users.noreply.github.com> Date: Mon, 11 Oct 2021 18:49:24 -0400 Subject: [PATCH] Enable experimental_tarball_format for container_bundle. (#1938) Resolves TODO. Seems to improve build time. Co-authored-by: aptenodytes-forsteri --- container/bundle.bzl | 18 ++++++++++++++---- docs/container.md | 5 +++-- tests/container/BUILD | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/container/bundle.bzl b/container/bundle.bzl index 7deb13490..43c2e74e2 100644 --- a/container/bundle.bzl +++ b/container/bundle.bzl @@ -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, ) @@ -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"], diff --git a/docs/container.md b/docs/container.md index 32c9b7c96..ee339ba33 100644 --- a/docs/container.md +++ b/docs/container.md @@ -8,8 +8,8 @@ Load these from `@io_bazel_rules_docker//container:container.bzl`. ## container_bundle
-container_bundle(name, extract_config, image_target_strings, image_targets, images,
-                 incremental_load_template, stamp, tar_output)
+container_bundle(name, experimental_tarball_format, extract_config, image_target_strings,
+                 image_targets, images, incremental_load_template, stamp, tar_output)
 
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. | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | +| 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" | | extract_config | - | Label | optional | //container/go/cmd/extract_config:extract_config | | image_target_strings | - | List of strings | optional | [] | | image_targets | - | List of labels | optional | [] | diff --git a/tests/container/BUILD b/tests/container/BUILD index c65929846..e26637493 100644 --- a/tests/container/BUILD +++ b/tests/container/BUILD @@ -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",