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.
This commit is contained in:
Mark Cave-Ayland 2022-10-17 21:08:12 +01:00 committed by Wolfgang Thaller
parent 0649693436
commit bde1485a9e
1 changed files with 11 additions and 3 deletions

View File

@ -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