hipages / php-fpm_exporter

A prometheus exporter for PHP-FPM.
Apache License 2.0
611 stars 123 forks source link

Non-root docker image version #338

Open Anastasios89 opened 11 months ago

Anastasios89 commented 11 months ago

Hello everyone,

some systems run with security contexts, which means that the container cannot run with root privileges.

Could you please also offer a non-root version docker image on docker hub?

Best regards.

EarthlingDavey commented 3 months ago

AFAICT you can do the following in your own Dockerfile. It seems to work as expected.

FROM hipages/php-fpm_exporter AS build-fpm-exporter

# Non-root user
USER 101
ffais commented 1 month ago

This is an example using nonroot google distroless image:

FROM golang:1.20.4 as builder

WORKDIR /go/src/github.com/hipages/php-fpm_exporter
COPY . .
RUN go mod download
RUN make build
RUN cp php-fpm_exporter /bin/php-fpm_exporter

FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=builder /bin/php-fpm_exporter /bin/php-fpm_exporter
EXPOSE     9253
ENTRYPOINT [ "/bin/php-fpm_exporter", "server" ]