Skip to content

Commit

Permalink
fix: use BuildKit instead of legacy builder to build the Hermetic Bui…
Browse files Browse the repository at this point in the history
…ld 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`
  • Loading branch information
diegomarquezp authored Nov 8, 2024
1 parent b0adcf9 commit 222fb45
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions hermetic_build/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 222fb45

Please sign in to comment.