From 84c49319a691ea943f9df0aa70b231753ef2360e Mon Sep 17 00:00:00 2001 From: James Eversole Date: Thu, 29 Dec 2022 17:57:34 -0600 Subject: [PATCH] Add UPX executable compression to Docker build in order to reduce binary and docker image sizes significantly --- examples/Dockerfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/Dockerfile b/examples/Dockerfile index 8288eb0..b07dd27 100644 --- a/examples/Dockerfile +++ b/examples/Dockerfile @@ -1,10 +1,18 @@ -FROM alpine:3.17.0 +FROM alpine:3.17.0 as builder + +RUN apk add --no-cache upx +ADD ./bin/Purr-musl /app/Purr-musl + +RUN upx /app/Purr-musl -o /app/Purr-musl-upx + +FROM scratch WORKDIR /app ADD ./views /app/views ADD ./src /app/src -ADD ./bin/Purr-musl /app/Purr-musl + +COPY --from=builder /app/Purr-musl-upx /app/Purr EXPOSE 3000 -ENTRYPOINT ["/app/Purr-musl"] +ENTRYPOINT ["/app/Purr"]