traefik / whoami

Tiny Go server that prints os information and HTTP request to output
https://traefik.io
Apache License 2.0
1.04k stars 223 forks source link

Add curl scratch binary and introduce docker healthcheck #81

Closed pduchnovsky closed 1 month ago

pduchnovsky commented 1 year ago

Add curl scratch binary and introduce docker healthcheck

Updated buildx.Dockerfile

jonasgeiler commented 1 month ago

I think it would be better to add a --healthcheck flag to the CLI, which just makes a HTTP request to /health and exits with 0 or 1, depending on the response. No need to include all of curl for this.

This would be very similar to how traefik does health checks, just with a flag instead of a subcommand: https://doc.traefik.io/traefik/operations/cli/#healthcheck

The flag could take an optional value which is the URL to make the request to, defaulting to http://localhost:80. So to make a health check you'd run it like this: /whoami --healthcheck or /whoami --healthcheck https://localhost:443.

If you don't know Go enough to implement it like this, I'd be happy to make the PR myself. I just wanted to suggest and discuss this instead of quietly opening a conflicting PR.

jonasgeiler commented 1 month ago

@pduchnovsky just noticed you've closed this PR. So are you working on a non-curl PR like I suggested? Or what's the reason?

pduchnovsky commented 1 month ago

@jonasgeiler I closed the PR because I no longer use the whoami container, and as a result, my interest in the project has shifted. Wishing you all the best with it!