Skip to content

Commit

Permalink
[trial-builds] Speed up first trial build by using real image as cache (
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmetzman authored Feb 7, 2023
1 parent 18f3e32 commit daef594
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
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

0 comments on commit daef594

Please sign in to comment.