From 222fb452e00bd195ad51389ea308993a7e1bc956 Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Thu, 7 Nov 2024 21:35:09 -0500 Subject: [PATCH] fix: use BuildKit instead of legacy builder to build the Hermetic Build images (#3338) Fixes the following error: ![image](https://github.com/user-attachments/assets/c4d20cbc-e3b3-48d6-9846-896854145857) [Docker Buildkit](https://docs.docker.com/build/buildkit/) is a more advanced version and more actively maintained. We confirmed locally that the error occurs with an old version of the docker builder and that it is fixed when using `DOCKER_BUILDKIT=1` --- .../cloudbuild-library-generation-push-prod.yaml | 2 ++ .../library_generation/cloudbuild-library-generation-push.yaml | 2 ++ hermetic_build/DEVELOPMENT.md | 3 --- hermetic_build/library_generation/tests/integration_tests.py | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.cloudbuild/library_generation/cloudbuild-library-generation-push-prod.yaml b/.cloudbuild/library_generation/cloudbuild-library-generation-push-prod.yaml index b3d6783087..1499c9053b 100644 --- a/.cloudbuild/library_generation/cloudbuild-library-generation-push-prod.yaml +++ b/.cloudbuild/library_generation/cloudbuild-library-generation-push-prod.yaml @@ -30,6 +30,8 @@ steps: "--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."] id: library-generation-build waitFor: ["-"] + env: + - 'DOCKER_BUILDKIT=1' options: logging: CLOUD_LOGGING_ONLY diff --git a/.cloudbuild/library_generation/cloudbuild-library-generation-push.yaml b/.cloudbuild/library_generation/cloudbuild-library-generation-push.yaml index 012cd26817..359c021f69 100644 --- a/.cloudbuild/library_generation/cloudbuild-library-generation-push.yaml +++ b/.cloudbuild/library_generation/cloudbuild-library-generation-push.yaml @@ -30,6 +30,8 @@ steps: "--file", ".cloudbuild/library_generation/library_generation.Dockerfile", "."] id: library-generation-build waitFor: ["-"] + env: + - 'DOCKER_BUILDKIT=1' options: logging: CLOUD_LOGGING_ONLY diff --git a/hermetic_build/DEVELOPMENT.md b/hermetic_build/DEVELOPMENT.md index e54c57e9ec..4ba3d4b9af 100644 --- a/hermetic_build/DEVELOPMENT.md +++ b/hermetic_build/DEVELOPMENT.md @@ -167,9 +167,6 @@ python hermetic_build/library_generation/cli/entry_point.py generate \ ``` Please note that the build only works when using the new [Docker BuildKit](https://docs.docker.com/build/buildkit/) (enabled through the `DOCKER_BUILDKIT` variable). - This is meant for local development only (in CloudTops) - GH Actions' Ubuntu-22.04 \ - [comes with the latest Docker version](https://github.com/actions/runner-images/blob/e74605cd6d5407469cf224802f25057bafc23d70/images/ubuntu/Ubuntu2204-Readme.md?plain=1#L81-L83) - and is able to handle the build properly using the (updated) legacy builder. 3. Set the version of gapic-generator-java diff --git a/hermetic_build/library_generation/tests/integration_tests.py b/hermetic_build/library_generation/tests/integration_tests.py index 5a1d5f7e53..a940069baa 100644 --- a/hermetic_build/library_generation/tests/integration_tests.py +++ b/hermetic_build/library_generation/tests/integration_tests.py @@ -202,6 +202,7 @@ def __build_image(cls, docker_file: str, cwd: str): subprocess.check_call( ["docker", "build", "-f", docker_file, "-t", image_tag, "."], cwd=cwd, + env=dict(os.environ, DOCKER_BUILDKIT="1"), ) @classmethod