You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To using --cache-from to use the previous bentobox-engine container as build cache.
However our build times for the bentobox-engine container is still around 12 minutes,
which is similar if just built from scratch without caching.
Investigation
The previous bentobox-engine used as build cache is built to the release build stage
which only contains layers from the base build stage + the Engine executable:
Encountering FROM base as release, Docker throws away all build build stage layers.
FROM ubuntu:20.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
# install apt runtime dependenciesRUN apt-get update && apt-get install -y --no-install-recommends \
libglfw3-dev xvfb xorg-dev ca-certificates
FROM base as build
# .... building FROM base as release
# clean apt-get cacheRUN rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/archives/*
# copy built binary into release imageCOPY --from=build /repo/sim/build/bentobox /bentobox
As such when --cache-from attempts to use layers as build cache only the very first layers
in the base build stage are available, causing the rest of the build build stage layers to be rebuilt.
Fix
Publish a 'build' variant of the bentobox-engine container with build build stage layers
and direct --cache-from to use that 'build' variant. This should result in better cached container builds.
Problem
Post #29, we switched the CI/CD from:
--cache-fromto use the previous bentobox-engine container as build cache.However our build times for the bentobox-engine container is still around 12 minutes,
which is similar if just built from scratch without caching.
Investigation
The previous bentobox-engine used as build cache is built to the
releasebuild stagewhich only contains layers from the
basebuild stage + the Engine executable:FROM base as release, Docker throws away allbuildbuild stage layers.As such when
--cache-fromattempts to use layers as build cache only the very first layersin the
basebuild stage are available, causing the rest of thebuildbuild stage layers to be rebuilt.Fix
Publish a 'build' variant of the bentobox-engine container with
buildbuild stage layersand direct
--cache-fromto use that 'build' variant. This should result in better cached container builds.