10 releases
0.1.22 | Dec 16, 2023 |
---|---|
0.1.20 | Dec 16, 2023 |
0.1.15 | Aug 25, 2023 |
0.1.14 | Jun 27, 2023 |
0.1.9 | Mar 2, 2023 |
#54 in HTTP client
153 downloads per month
3MB
Contains (ELF exe, 1.5MB) bin/httpget-tls.x86_64, (ELF exe, 1.5MB) bin/httpget-tls, (ELF exe, 535KB) bin/httpget, (ELF exe, 1MB) bin/httpget-tls.aarch64, (ELF exe, 535KB) bin/httpget.x86_64, (ELF exe, 470KB) bin/httpget.aarch64
HttpGet
This is a tiny client that sends an HTTP GET request to the parameter that you specify on the command line. This is statically compiled, so it is useful to toss into distroless or scratch containers that need to have an HTTP client for health check purposes.
Why build this?
This project came to be because a friend wanted to run health checks in a distroless container, and I wanted to make a binary that was as small as it could be. I did a writeup about that process, so if you want more information please read this blog post.
It's also becoming a bigger trend to use either distroless containers, or containers based on scratch
for security/image size reasons; this project allows a minimal dependency client that can only do GET requests, and has negligible footprint on container size.
Just how small is this?
Let's compare the binary size against other popular ones, specifically against wget
and curl
, measured from the binary & its dependencies in the alpine
container
Binary | Size |
---|---|
curl |
6.1mb |
wget |
1.4mb |
httpget , no TLS |
531kb |
httpget , with rustls |
1.2mb |
So, all in all, it's quite minimal.
Installing HttpGet
Currently, only x86_64 binaries are released. If you are hoping to use this with ARM-based images, you will need to build them yourself.
Docker
Since this binary is primarily meant to be used for Docker health checks, the easiest way to consume this binary is through Docker. The binaries are published in the ghcr.io/cryptaliagy/httpget
repository in scratch containers, and you can use the version tags or latest
/latest-tls
.
Any released version tag includes an equivalent tls
tag. See below for an example Dockerfile, or see this project for an example usecase.
FROM golang:latest as build
# Build steps here
# (...)
# In the end we get a binary at /app/bin/example with our web service
FROM ghcr.io/cryptaliagy/httpget:latest as httpget
FROM scratch as runner
COPY --from=build /app/bin/example /example
COPY --from=httpget /httpget /httpget
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD ["/httpget", "http://localhost:8080/healthz"]
CMD ["/example"]
Another option is to put the httpget
image before the build stage and copy it into the output directory for the build stage, so your final image is only a single layer:
FROM ghcr.io/cryptaliagy/httpget:latest as httpget
FROM golang:latest as build
# Build steps here
# (...)
# In the end we get a binary at /app/bin/example with our web service
COPY --from=httpget /httpget /app/bin/httpget
FROM scratch as runner
COPY --from=build /app/bin /bin
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD ["/bin/httpget", "http://localhost:8080/healthz"]
CMD ["/bin/example"]
Github Releases (Direct Download)
The regular binary and the TLS binary are available through Github Releases, and can be downloaded here. The httpget
binary can only use http://
protocol URLs, and the httpget-tls
can use either http://
or https://
.
Install with Cargo
This project is published on crates.io, and can be installed using cargo
with the command cargo install httpget
. This will not produce a statically-linked binary: for that, you must ensure that you've installed the correct *-unknown-linux-musl
target.
You can also clone this repository and run cargo install --path .
to install through Cargo
Dependencies
~0.2–8MB
~76K SLoC