Gatus in Docker Container Healthcheck
Describe the feature request
I would like to see a healthcheck when running gatus in a docker container, specifically I want to see healthy next to the container uptime when running docker ps. I tried my hand at implementing it myself but wasn't able to come up with a clean solution without modifying the dockerfile.
Because the gatus binary is copied into a scratch docker container, there aren't any other binaries to use to run the healthcheck on (common things like curl/wget/etc.). I tried copying a curl binary into the container so I could capture the json at the /health endpoint but then I didn't have any tools like grep to check the data that comes back.
If you wanted to keep everything in the binary, you could add an optional argument (like gatus --health) that causes gatus to simply return the same status that is generated from the /health endpoint (return 0 for UP and return 1 for DOWN).
Why do you personally want this feature to be implemented?
By seeing the health status of gatus in docker, I can better determine the status of the gatus container along with all the other containers I am running.
How long have you been using this project?
Just started.
Additional information
Thanks!
I built Gatus with a "fail fast" mechanism in mind. This means that if something is wrongly configured, it'll fail on start.
I guess an issue that could lead to this is if access to the database suddenly stopped working, but even so, right now, Gatus' health status does not change from up to down if that happens, so this wouldn't be useful.
Perhaps when that's implemented, this could be worth implementing, but for now, I don't see the value.
Regardless, thank you for creating an issue!
There's some use here in certain deployment scenarios, e.g. AWS ECS, though it's more of a cosmetic thing.
As an example, a happily running Gatus container will show up with a health status of UNKNOWN. I know Gatus is running because if the process was failing/container crashing, ECS would report that, but it still irks me 😅.
To be clear, I'm not saying my mild irk is worth making changes for.
Well now that I have more details, I'm not completely against the idea
A subcommand on the binary can be added that execs an http request on the /health endpoint.
That way you dont have to add any deps on the container image at all!
ie /gatus healthcheck
I would also like to chime in that I've had gatus just hang in some adverse conditions (i.e. container started before networking is up). Having a healthcheck that actually fires a request to the /health endpoint would help here as well.