Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slim healthchecks #264

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add slim healthchecks #264

wants to merge 2 commits into from

Conversation

CodaBool
Copy link

@CodaBool CodaBool commented May 18, 2024

I put out a Issue here where I requested healthchecks. I looked back on it since I also saw someone else requesting it on Reddit here.

I wanted to see if I could find an efficient way to add them into this project.

Like I mentioned in my issue there are several ways to do Docker healthchecks.

The simplest is to use a wget or curl command. However, in your selected image bitnami/minideb. Those are not there. An alternative at that point can be to use netcat / nc but that also is not installed.

Since this image is close to distroless and that is a good spot to be in for Docker images. I investigated trying to add healthchecks while still keeping the image as small as possible

image

I was able to use a blog I found to make a 608Kb healthcheck.

A more maintainable alternative would be to use minideb's install_packages wget and perform a wget healthcheck like this

wget --no-verbose --tries=1 --spider http://localhost:8080 || exit 1

This wget install would add 4.78Mb in size to the image. But would be minimal in code (1 line of Dockerfile code). However, if you went further down the distroless images with something like gcr.io/distroless/static. Then you would no longer be able to use a debian package manager and would need to get the package from busybox with something like this:

FROM busybox:uclibc AS busybox
FROM gcr.io/distroless/static

COPY --from=busybox /bin/wget /usr/bin/wget

Which should only add 1.17Mb, so not too bad there. As another alternative solution that would only be 2 lines of Dockerfile code.

Just wanted to lay out some options for your project. If you value image size & security we can refine this PR. If you just want maintainability then the 1 line install_packages command should work fine for your minideb image you've selected.

Thanks for putting this project out there I've been really enjoying it.

logs

When I tested this docker-compose.yml the health checks spammed the logs (I think it sends one every ~10-30 seconds. It might be useful to have an endpoint that doesn't create a stdout log and have the health check hit that endpoint instead

app_port

The .rs file I committed can accept an app_port configuration. But I think it's fine to be opinionated and use an unconfigurable port 8080 app side. Especially with how many env vars already exist for the project.

So that's something that should get removed from my pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant