From 09aa735a458ce74b69fe4fc940f9adb2bccccbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Ars?= <29622411+gaetanars@users.noreply.github.com> Date: Thu, 14 Dec 2023 10:31:04 +0100 Subject: [PATCH] feat: use distroless base image --- Dockerfile | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3f590b83..aa13c466 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,20 +12,9 @@ WORKDIR /src RUN GOGC=off go build -mod=vendor -v -o /sql_exporter . # multistage -FROM alpine:3.18.3 +FROM gcr.io/distroless/static:nonroot -RUN apk --update upgrade && \ - apk add curl ca-certificates && \ - apk add tzdata && \ - update-ca-certificates && \ - rm -rf /var/cache/apk/* +USER nonroot:nonroot +COPY --from=bin --chown=nonroot:nonroot --chmod=0755 /usr/bin/sql_exporter / -COPY --from=builder /sql_exporter /usr/bin/sql_exporter - -# Run the image as a non-root user -RUN adduser -D prom -RUN chmod 0755 /usr/bin/sql_exporter - -USER prom - -CMD sql_exporter +ENTRYPOINT ["/sql_exporter"]