From 6467bd58507c7afb9de5e697477cdd66d5d647ba Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 9 Aug 2023 08:56:34 +0200 Subject: [PATCH] Create static Mg and use FROM scratch stage to reduce image size We don't need to carry an entire Alpine installation just to run Mg, and thanks to musl libc's ability to build actual static binaries we now use Docker only for shipping our static binary. At a fraction of the size! Signed-off-by: Joachim Wiberg --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 770288c..8d1b4c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,12 @@ RUN apk --no-cache add --virtual .build-dependencies \ WORKDIR /root COPY . ./ -RUN git clean -fdx; ./autogen.sh && \ - ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var && make install-strip +RUN git clean -fdx +RUN ./autogen.sh +RUN ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var CFLAGS=-static +RUN make install-strip -FROM alpine:latest +FROM scratch COPY --from=0 /usr/bin/mg /usr/bin/mg COPY --from=0 /usr/share/doc/mg /usr/share/doc/mg