A minimal binary to include in containers that can perform a get request to check if the service is healthy
- Rust 89.1%
- Shell 10.9%
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| container-command.sh | ||
| LICENSE | ||
| README.md | ||
minimal-GET-healthcheck
Inspired by this aricle I want to try to recreate it but without any external dependencies. This will also let me try both rust and building HTTP from scratch.
A minimal binary to include in containers that can perform a get request to check if the service is healthy
Making it real small
Adivce from https://github.com/johnthagen/min-sized-rust.
If you want to just run then cargo build --release --target x86_64-unknown-linux-musl
- This is about
404kB
If you are ok with nightly then podman run -v $PWD:/volume:Z --rm -it clux/muslrust:1.97.0-nightly-2026-04-14 /volume/container-command.sh
- This will rebuild stdlib and turn off some other features. Read the github for more details
- Built using docker as rebuilding stdlib was a bit finicity
- This is about
90kB
If you want the best size then you can further compress with upx upx --best --lzma target/x86_64-unknown-linux-gnu/release/minimal-GET-healthcheck
- This comes with a few issues with using upx from here
- The whole code will be fully uncompressed in virtual memory, while in a regular EXE or DLL, only the code actually used is loaded in memory. This is especially relevant if only a small portion of the code in your EXE/DLL is used at each run.
- If there are multiple instances of your DLL and EXE running, their code can't be shared across the instances, so you'll be using more memory.
- If your EXE/DLL is already in cache, or on a very fast storage medium, or if the CPU you're running on is slow, you will experience reduced # startup speed as decompression will still have to take place, and you won't benefit from the reduced.