Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trial-builds] Speed up first trial build by using real image as cache #9535

Merged
merged 6 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infra/base-images/base-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Base image for all other images.

ARG parent_image=ubuntu:20.04
ARG parent_image=ubuntu:20.04@sha256:4a45212e9518f35983a976eead0de5eecc555a2f047134e9dd2cfc589076a00d

FROM $parent_image

Expand Down
2 changes: 1 addition & 1 deletion infra/build/functions/build_and_push_test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def gcb_build_and_push_images(test_image_suffix):
directory = os.path.join('infra', 'base-images', base_image)
step = build_lib.get_docker_build_step([main_tag, test_tag],
directory,
buildkit_cache_image=test_tag,
use_buildkit_cache=True,
src_root='.')
steps.append(step)

Expand Down
16 changes: 7 additions & 9 deletions infra/build/functions/build_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _make_image_name_architecture_specific(image_name, architecture):

def get_docker_build_step(image_names,
directory,
buildkit_cache_image=None,
use_buildkit_cache=False,
src_root='oss-fuzz',
architecture='x86_64'):
"""Returns the docker build step."""
Expand All @@ -398,17 +398,15 @@ def get_docker_build_step(image_names,
'args': args,
'dir': directory,
}
# Handle buildkit args
# Note that we mutate "args" after making it a value in step.

if buildkit_cache_image is not None:
if use_buildkit_cache:
env = ['DOCKER_BUILDKIT=1']
step['env'] = env
assert buildkit_cache_image in args
additional_args = [
'--build-arg', 'BUILDKIT_INLINE_CACHE=1', '--cache-from',
buildkit_cache_image
]
args.extend(additional_args)
args.extend(['--build-arg', 'BUILDKIT_INLINE_CACHE=1'])
for image in image_names:
args.extend(['--cache-from', image])

args.append('.')

return step
Expand Down