Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.
This repository was 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

Description

@mrzzy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingci/cdGithub Actions CIengineArea: Engineinfra

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions