Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Docker Caching: Fix bentobox-engine with losing 'build' build stage layers as build cache #64

Open
mrzzy opened this issue Feb 20, 2021 · 0 comments
Labels
bug Something isn't working ci/cd Github Actions CI engine Area: Engine infra
Milestone

Comments

@mrzzy
Copy link
Collaborator

mrzzy commented Feb 20, 2021

Problem

Post #29, we switched the CI/CD from:

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 dependencies
RUN 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 cache
RUN rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/archives/*
# copy built binary into release image
COPY --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.

@mrzzy mrzzy added bug Something isn't working ci/cd Github Actions CI engine Area: Engine infra labels Feb 20, 2021
@mrzzy mrzzy added this to the v0.2 milestone Feb 20, 2021
@mrzzy mrzzy self-assigned this Feb 20, 2021
@mrzzy mrzzy changed the title Docker Caching Again: Use bentobox-engine with 'build' build stage as build cache Docker Caching: Fix bentobox-engine with losing 'build' build stage layers as build cache Feb 20, 2021
@mrzzy mrzzy removed their assignment Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working ci/cd Github Actions CI engine Area: Engine infra
Projects
None yet
Development

No branches or pull requests

1 participant