Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cryptaliagy/httpget
a ridiculously simple and small http get client to use for health checks
https://github.com/cryptaliagy/httpget
client container distroless distroless-docker docker healthcheck http rust web
Last synced: 29 days ago
JSON representation
a ridiculously simple and small http get client to use for health checks
- Host: GitHub
- URL: https://github.com/cryptaliagy/httpget
- Owner: cryptaliagy
- Created: 2023-02-28T02:55:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-29T16:24:43.000Z (7 months ago)
- Last Synced: 2024-10-06T17:01:25.813Z (about 1 month ago)
- Topics: client, container, distroless, distroless-docker, docker, healthcheck, http, rust, web
- Language: Rust
- Homepage:
- Size: 42 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HttpGet
[![release](https://github.com/cryptaliagy/httpget/actions/workflows/release.yaml/badge.svg)](https://github.com/cryptaliagy/httpget/actions/workflows/release.yaml)
[![test](https://github.com/cryptaliagy/httpget/actions/workflows/test.yaml/badge.svg)](https://github.com/cryptaliagy/httpget/actions/workflows/test.yaml)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](https://natalia.dev/blog/2023/03/docker-health-checks-on-distroless-containers-with-rust/).
It's also becoming a bigger trend to use either [distroless](https://github.com/GoogleContainerTools/distroless#why-should-i-use-distroless-images) containers, or containers based on [`scratch`](https://support.snyk.io/hc/en-us/articles/360004012857-What-are-docker-scratch-based-images-) 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
Binaries are provided for both x86_84 and arm64 architectures, both as Docker images and as direct download from the Github Releases page.
### 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](https://github.com/cryptaliagy/httpget-example/blob/main/Dockerfile) for an example usecase.
```dockerfile
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 /httpgetHEALTHCHECK --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:
```dockerfile
FROM ghcr.io/cryptaliagy/httpget:latest as httpgetFROM 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](https://github.com/cryptaliagy/httpget/releases). 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](https://crates.io/crates/httpget), 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