Skip to content

Commit

Permalink
Create static Mg and use FROM scratch stage to reduce image size
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
troglobit committed Aug 9, 2023
1 parent efe8798 commit 6467bd5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6467bd5

Please sign in to comment.