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"]