# === Builder Stage === FROM alpine:3.18.4@sha256:48d9183eb12a05c99bcc0bf44a003607b8e941e1d4f41f9ad12bdcc4b5672f86 as builder # Install cmake to manage the build process. Removing cache by `docker builder prune` RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \ apk add --cache-dir /var/cache/apk g++ make cmake # Alternatively, you can use --no-cache option to avoid creating a cache inside the container. # However, note that this will also prevent the use of the shared cache, affecting caching efficiency. # Example: # RUN apk --no-cache add g++ mahe 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 alpine:3.18.4@sha256:48d9183eb12a05c99bcc0bf44a003607b8e941e1d4f41f9ad12bdcc4b5672f86 # 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"]