Skip to content

Commit

Permalink
Use BuildKit to build the images
Browse files Browse the repository at this point in the history
This greatly improves caching in my experience. See
https://docs.docker.com/engine/reference/builder/#buildkit and
https://docs.docker.com/engine/reference/commandline/build/#specifying-external-cache-sources
for details.

gitlint-ignore: body-max-line-length
Signed-off-by: Stephen Kitt <[email protected]>
  • Loading branch information
skitt authored and mangelajo committed Sep 25, 2020
1 parent 32eb28f commit 8a8f116
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions scripts/shared/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ if [[ "$cache" = true ]]; then
fi

# Rebuild the image to update any changed layers and tag it back so it will be used.
buildargs_flag=''
[[ -z "${buildargs}" ]] || buildargs_flag="--build-arg ${buildargs}"
docker build -t ${local_image} ${cache_flag} -f ${dockerfile} ${buildargs_flag} .
buildargs_flag='--build-arg BUILDKIT_INLINE_CACHE=1'
[[ -z "${buildargs}" ]] || buildargs_flag="${buildargs_flag} ${buildargs}"
DOCKER_BUILDKIT=1 docker build -t ${local_image} ${cache_flag} -f ${dockerfile} ${buildargs_flag} .
docker tag ${local_image} ${cache_image}

0 comments on commit 8a8f116

Please sign in to comment.