Add curl/wget/nc etc to allow docker health check
Image is Debian 12 slim based so does not include curl ping wget or nc meaning docker healthchecks arent possible. Would be as simple as adding adding "curl" or "wget" to line 64/65 of the Dockerfile https://github.com/redimp/otterwiki/blob/main/Dockerfile
Hey @jamess60, thanks for bringing this up. This is for sure a good idea. I've not thought about it, since I deploy the otterwikis in kubernetes where I can run the liveness- and readiness Probes from the outside of the container, see the helm chart.
What do you think, should this be added to the Dockerfile, too?
HEALTHCHECK --interval=1m --timeout=3s --retries=3 \
CMD curl -A "docker-healthcheck" -f http://localhost:8080/-/healthz || exit 1
Hey @redimp - thanks for looking into this :)
Not yet messed with Kubernetes personally so not familiar with how its health checking works.
Only modification to the dockerfile should be the inclusion of the package (curl or wget, although they share some dependencies so adding both is only a 3MB difference).
In my lab, I've been adding the health check to the compose file, simple example below:
it-tools:
container_name: it-tools
image: corentinth/it-tools:latest
ports:
- 5008:80
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://127.0.0.1/ || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 20s
Unsure what endpoint is best to curl for OtterWiki (Maybe it has some sort of api call?), but usually just probing the web server is enough.
Released in v2.10.6.
As an fyi, this change results in persistent raised CPU usage. Not overly concerning, but figured I'd note it here.
Hey @bradbeattie, thanks for sharing this... thats a surprisingly increase of cpu resources used.
Is this purely from the Dockerfile healthcheck?
It would seem so.
Upgrading to the latest version:
After adding the following override healthcheck to my docker-compose.yml:
healthcheck:
test: ["CMD", "curl", "-A", "docker-healthcheck", "-f", "http://localhost:8080/-/healthz" ]
start_period: 10s
interval: 10m
timeout: 3s
retries: 3
Thanks for digging into this. Reducing the interval from 1m to 5m seems like a sensible middle ground to me. Will update the Dockerfiles.
Fix released in 2.14.2.