From bde1485a9edaafed72d70b21c6ab997561f39bae Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Mon, 17 Oct 2022 21:08:12 +0100 Subject: [PATCH] Dockerfile: only copy the build directory artifacts into the final release image Use the docker multi-stage build functionality to perform the Retro68 build in a temporary build image, and then copy the final build directory into a fresh release image. This reduces the final release image size from 9.2GB to 2.6GB. --- Dockerfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2acc1e6e0b..ffe7550605 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ # vim:ft=dockerfile -FROM ubuntu:20.04 +# Base image +FROM ubuntu:20.04 AS base RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y \ @@ -8,8 +9,15 @@ RUN apt-get update && \ libboost-all-dev bison texinfo \ ruby flex curl g++ +# Build image +FROM base AS build + ADD . /Retro68 -RUN mkdir /Retro68-build +RUN mkdir /Retro68-build && \ + bash -c "cd /Retro68-build && bash /Retro68/build-toolchain.bash" -RUN bash -c "cd /Retro68-build && bash /Retro68/build-toolchain.bash --clean-after-build" +# Release image +FROM base AS release + +COPY --from=build /Retro68-build/toolchain /Retro68-build/toolchain