eko / pihole-exporter

A Prometheus exporter for PI-Hole's Raspberry PI ad blocker
MIT License
924 stars 106 forks source link

[F/R] add healthcheck to dockerfile #46

Open pvnovarese opened 4 years ago

pvnovarese commented 4 years ago

Have you considered adding a simple healthcheck to the Dockerfile?

I think to do this you will need to change the base image from scratch to alpine, which will increase the resulting final image (on my system it more than tripled it), and I have an appreciation for keeping this as simple and minimal as possible. Also I am not super familiar with the ins and outs of exporters so I'm not really sure how much value a healthcheck will even add in this case.

The other possibility would be to add a built-in check function to the pihole-exporter itself, which might keep the bloat down a bit.

pvn@gyarados /home/pvn> docker image ls | grep pihole-exporter
pvnovarese/pihole-exporter         latest              16e60d69390e        15 minutes ago      8.07MB
ekofr/pihole-exporter              latest              35e4393afb6f        2 weeks ago         2.45MB

Anyway, all I did is change

ARG IMAGE=alpine

and then add

HEALTHCHECK CMD wget --spider http://127.0.0.1:9617/metrics || exit 1

I can submit a PR if you're interested in doing this.

eko commented 3 years ago

Hi @pvnovarese,

First, sorry about the delay.

I will be happy to have a health check if you want to submit a PR. Elsewhere I could take a look at it in the next days.

Thank you

SuperSandro2000 commented 3 years ago

Adding such a healthcheck will only increase start time to one minute. This is because the first check fails and the next one is only one minute after. This is relevant for reverse proxies like traefik which remove routes when the container is not healthy.

vremenar commented 7 months ago

Healthcheck added to docker-compose.yml so you can implement it that way.