From ad4cfb4b9cdf31f98a8d2113ab27681ec229dc7b Mon Sep 17 00:00:00 2001 From: Alexis Couvreur Date: Tue, 10 Sep 2024 22:55:25 -0400 Subject: [PATCH] build(docker): reduce image size by ~10% Switching from alpine to scratch as base image. --- Dockerfile | 7 +++---- Makefile | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 50ac57a..1dd771f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM golang:1.22 AS build +RUN mkdir -p /etc/sablier/themes WORKDIR /src RUN go env -w GOMODCACHE=/root/.cache/go-build @@ -18,11 +19,9 @@ ARG TARGETARCH RUN --mount=type=cache,target=/root/.cache/go-build \ make BUILDTIME=${BUILDTIME} VERSION=${VERSION} GIT_REVISION=${REVISION} ${TARGETOS}/${TARGETARCH} -FROM alpine:3.20.3 - -RUN mkdir -p /etc/sablier/themes -EXPOSE 10000 +FROM scratch +COPY --from=build /etc/sablier/themes /etc/sablier/themes COPY --from=build /src/sablier* /bin/sablier COPY docker/sablier.yaml /etc/sablier/sablier.yaml diff --git a/Makefile b/Makefile index f8115af..4736df5 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ test-plugin-caddy: .PHONY: docker docker: - docker build -t acouvreur/sablier:local . + docker build --build-arg BUILDTIME=$(BUILDTIME) --build-arg VERSION=$(VERSION) --build-arg REVISION=$(GIT_REVISION) -t acouvreur/sablier:local . caddy: docker build -t caddy:local plugins/caddy