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%
Find a file
2026-04-15 06:49:34 +01:00
src Found way of getting building std-lib to work and still be statically linked 2026-04-15 06:40:32 +01:00
.gitignore Added ./target to gitignore 2026-02-01 16:23:58 +00:00
Cargo.toml Found way of getting building std-lib to work and still be statically linked 2026-04-15 06:40:32 +01:00
container-command.sh Found way of getting building std-lib to work and still be statically linked 2026-04-15 06:40:32 +01:00
LICENSE Initial commit 2026-01-30 17:08:09 +00:00
README.md sp 2026-04-15 06:49:34 +01:00

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
    1. 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.
    2. 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.
    3. 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.