From 44895e5287c27bea160f2371264f9a32ad8b2714 Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Thu, 7 Apr 2022 16:28:43 +0200 Subject: [PATCH 1/2] Improve build cache for docker images - Save all layer's cache - Use cache with fallback to a latest tags --- tests/ci/docker_images_check.py | 3 ++- tests/ci/docker_test.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/ci/docker_images_check.py b/tests/ci/docker_images_check.py index 43671e3a2f7..57227ef307e 100644 --- a/tests/ci/docker_images_check.py +++ b/tests/ci/docker_images_check.py @@ -237,9 +237,10 @@ def build_and_push_one_image( "docker buildx build --builder default " f"--label build-url={GITHUB_RUN_URL} " f"{from_tag_arg}" - f"--build-arg BUILDKIT_INLINE_CACHE=1 " f"--tag {image.repo}:{version_string} " f"--cache-from type=registry,ref={image.repo}:{version_string} " + f"--cache-from type=registry,ref={image.repo}:latest " + f"--cache-to type=inline,mode=max " f"{push_arg}" f"--progress plain {image.full_path}" ) diff --git a/tests/ci/docker_test.py b/tests/ci/docker_test.py index 0d1c554026f..8a0c4a0dfce 100644 --- a/tests/ci/docker_test.py +++ b/tests/ci/docker_test.py @@ -124,8 +124,9 @@ class TestDockerImageCheck(unittest.TestCase): self.assertIn( f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} " "--build-arg FROM_TAG=version " - "--build-arg BUILDKIT_INLINE_CACHE=1 --tag name:version --cache-from " - "type=registry,ref=name:version --push --progress plain path", + "--tag name:version --cache-from type=registry,ref=name:version " + "--cache-from type=registry,ref=name:latest " + "--cache-to type=inline,mode=max --push --progress plain path", mock_popen.call_args.args, ) self.assertTrue(result) @@ -141,8 +142,9 @@ class TestDockerImageCheck(unittest.TestCase): self.assertIn( f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} " "--build-arg FROM_TAG=version2 " - "--build-arg BUILDKIT_INLINE_CACHE=1 --tag name:version2 --cache-from " - "type=registry,ref=name:version2 --progress plain path", + "--tag name:version2 --cache-from type=registry,ref=name:version2 " + "--cache-from type=registry,ref=name:latest " + "--cache-to type=inline,mode=max --progress plain path", mock_popen.call_args.args, ) self.assertTrue(result) @@ -157,8 +159,9 @@ class TestDockerImageCheck(unittest.TestCase): mock_machine.assert_not_called() self.assertIn( f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} " - "--build-arg BUILDKIT_INLINE_CACHE=1 --tag name:version2 --cache-from " - "type=registry,ref=name:version2 --progress plain path", + "--tag name:version2 --cache-from type=registry,ref=name:version2 " + "--cache-from type=registry,ref=name:latest " + "--cache-to type=inline,mode=max --progress plain path", mock_popen.call_args.args, ) self.assertFalse(result) From 8111010815cb77f177254a79beda2ac433b5487a Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Thu, 7 Apr 2022 17:08:56 +0200 Subject: [PATCH 2/2] Rebuild a builder for test --- docker/docs/builder/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/docs/builder/Dockerfile b/docker/docs/builder/Dockerfile index 906312a19a2..061251aa7f0 100644 --- a/docker/docs/builder/Dockerfile +++ b/docker/docs/builder/Dockerfile @@ -1,4 +1,3 @@ -# rebuild in #33610 # docker build -t clickhouse/docs-builder . FROM ubuntu:20.04