otterwiki icon indicating copy to clipboard operation
otterwiki copied to clipboard

Add curl/wget/nc etc to allow docker health check

Open jamess60 opened this issue 8 months ago • 2 comments

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

jamess60 avatar Apr 23 '25 09:04 jamess60

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

redimp avatar Apr 23 '25 21:04 redimp

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.

jamess60 avatar Apr 24 '25 11:04 jamess60

Released in v2.10.6.

redimp avatar Apr 28 '25 22:04 redimp

As an fyi, this change results in persistent raised CPU usage. Not overly concerning, but figured I'd note it here.

Image

bradbeattie avatar Oct 26 '25 20:10 bradbeattie

Hey @bradbeattie, thanks for sharing this... thats a surprisingly increase of cpu resources used.

Is this purely from the Dockerfile healthcheck?

redimp avatar Oct 26 '25 22:10 redimp

It would seem so.

Upgrading to the latest version:

Image

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
Image

bradbeattie avatar Oct 26 '25 22:10 bradbeattie

Thanks for digging into this. Reducing the interval from 1m to 5m seems like a sensible middle ground to me. Will update the Dockerfiles.

redimp avatar Oct 27 '25 08:10 redimp

Fix released in 2.14.2.

redimp avatar Nov 09 '25 17:11 redimp