# === Builder Stage === FROM ubuntu as builder # Install cmake to manage the build process. Removing cache by `docker builder prune` RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \ rm -f /etc/apt/apt.conf.d/docker-clean \ && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \ && apt-get update \ && apt-get install -y --no-install-recommends g++ make cmake # Copy all source files from the current directory to /app in the image COPY CMakeLists.txt . COPY src ./src # Configuring, building and install the app RUN cmake . \ && make \ && make install # === Production Stage === FROM ubuntu # Copy only the built artifacts from the builder stage COPY --from=builder /usr/local/bin/HelloWorldApp /HelloWorldApp # Setting entry point to the app binary ENTRYPOINT ["/HelloWorldApp"]