Merge pull request #36041 from ClickHouse/docker-cache

Docker cache
This commit is contained in:
alesapin 2022-04-07 17:25:06 +02:00 committed by GitHub
commit e2167b8fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -1,4 +1,3 @@
# rebuild in #33610
# docker build -t clickhouse/docs-builder . # docker build -t clickhouse/docs-builder .
FROM ubuntu:20.04 FROM ubuntu:20.04

View File

@ -237,9 +237,10 @@ def build_and_push_one_image(
"docker buildx build --builder default " "docker buildx build --builder default "
f"--label build-url={GITHUB_RUN_URL} " f"--label build-url={GITHUB_RUN_URL} "
f"{from_tag_arg}" f"{from_tag_arg}"
f"--build-arg BUILDKIT_INLINE_CACHE=1 "
f"--tag {image.repo}:{version_string} " f"--tag {image.repo}:{version_string} "
f"--cache-from type=registry,ref={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"{push_arg}"
f"--progress plain {image.full_path}" f"--progress plain {image.full_path}"
) )

View File

@ -124,8 +124,9 @@ class TestDockerImageCheck(unittest.TestCase):
self.assertIn( self.assertIn(
f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} " f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} "
"--build-arg FROM_TAG=version " "--build-arg FROM_TAG=version "
"--build-arg BUILDKIT_INLINE_CACHE=1 --tag name:version --cache-from " "--tag name:version --cache-from type=registry,ref=name:version "
"type=registry,ref=name:version --push --progress plain path", "--cache-from type=registry,ref=name:latest "
"--cache-to type=inline,mode=max --push --progress plain path",
mock_popen.call_args.args, mock_popen.call_args.args,
) )
self.assertTrue(result) self.assertTrue(result)
@ -141,8 +142,9 @@ class TestDockerImageCheck(unittest.TestCase):
self.assertIn( self.assertIn(
f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} " f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} "
"--build-arg FROM_TAG=version2 " "--build-arg FROM_TAG=version2 "
"--build-arg BUILDKIT_INLINE_CACHE=1 --tag name:version2 --cache-from " "--tag name:version2 --cache-from type=registry,ref=name:version2 "
"type=registry,ref=name:version2 --progress plain path", "--cache-from type=registry,ref=name:latest "
"--cache-to type=inline,mode=max --progress plain path",
mock_popen.call_args.args, mock_popen.call_args.args,
) )
self.assertTrue(result) self.assertTrue(result)
@ -157,8 +159,9 @@ class TestDockerImageCheck(unittest.TestCase):
mock_machine.assert_not_called() mock_machine.assert_not_called()
self.assertIn( self.assertIn(
f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} " f"docker buildx build --builder default --label build-url={GITHUB_RUN_URL} "
"--build-arg BUILDKIT_INLINE_CACHE=1 --tag name:version2 --cache-from " "--tag name:version2 --cache-from type=registry,ref=name:version2 "
"type=registry,ref=name:version2 --progress plain path", "--cache-from type=registry,ref=name:latest "
"--cache-to type=inline,mode=max --progress plain path",
mock_popen.call_args.args, mock_popen.call_args.args,
) )
self.assertFalse(result) self.assertFalse(result)