From 452fe86288fa5ad396cac6af84e8fc7a680b15d7 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Mon, 12 Feb 2024 23:56:29 +0100 Subject: Use scratch on final step This reduce the final image size significantly. --- OpenSSL/3.1.1-minimal/Dockerfile | 4 +++- cJSON/1.7.16/Dockerfile | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenSSL/3.1.1-minimal/Dockerfile b/OpenSSL/3.1.1-minimal/Dockerfile index b99eb8d..770ebc9 100644 --- a/OpenSSL/3.1.1-minimal/Dockerfile +++ b/OpenSSL/3.1.1-minimal/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine +FROM alpine as base RUN apk update && apk add \ git \ make \ @@ -17,3 +17,5 @@ RUN ./config -ffunction-sections -fdata-sections \ RUN make -j$(nproc --all) RUN make test RUN make install +FROM scratch +COPY --from=base /opt/spm/openssl-3.1.1 /opt/spm/openssl-3.1.1 diff --git a/cJSON/1.7.16/Dockerfile b/cJSON/1.7.16/Dockerfile index e14a706..bb83f99 100644 --- a/cJSON/1.7.16/Dockerfile +++ b/cJSON/1.7.16/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine +FROM alpine as base ARG PREFIX=/opt/spm/cjson-1.7.16 RUN apk update && apk add \ git \ @@ -15,3 +15,5 @@ RUN cmake -B build \ -DCMAKE_C_FLAGS="-ffunction-sections -fdata-sections" RUN cmake --build build/ --parallel $(nproc --all) RUN cmake --install build/ +FROM scratch +COPY --from=base /opt/spm/cjson-1.7.16 /opt/spm/cjson-1.7.16 -- cgit v1.2.3