Dockerfile : multi-phase to reduce image from 224 MB to 10 MB

This commit is contained in:
saundersp 2024-07-02 20:45:44 +02:00
parent 9af11bd4ec
commit 73d0996c30

View File

@ -1,4 +1,4 @@
FROM alpine:3.20.0 FROM alpine:3.20.1 AS builder
RUN apk add --no-cache \ RUN apk add --no-cache \
make=4.4.1-r2 \ make=4.4.1-r2 \
@ -13,4 +13,16 @@ COPY *.cpp *.hpp Makefile ./
RUN make -j "$(nproc)" RUN make -j "$(nproc)"
ENTRYPOINT ["bin/data"] FROM alpine:3.20.1
RUN apk add --no-cache \
libstdc++=13.2.1_git20240309-r0 \
&& adduser --disabled-password saundersp
USER saundersp
WORKDIR /home/saundersp/sorting_algorithms
COPY --from=builder /home/saundersp/sorting_algorithms/bin/data .
ENTRYPOINT ["./data"]