Build a fully static HAProxy binary for Linux (musl) using Alpine in Docker. Dependencies (zlib, PCRE2, OpenSSL) are built from source and linked statically; the result is suitable for minimal or FROM scratch–style images.
Prebuilt static binaries are committed under dist/. haproxy-latest always points at the current version (currently 3.3.6); pin to a specific version if you prefer reproducible fetches.
Using wget:
# linux/amd64 — latest
wget -O haproxy https://github.com/styliteag/haproxy-static-build/raw/main/dist/linux_amd64/haproxy-latest
chmod +x haproxy
# linux/arm64 — latest
wget -O haproxy https://github.com/styliteag/haproxy-static-build/raw/main/dist/linux_arm64/haproxy-latest
chmod +x haproxy
# pin to a specific version
wget -O haproxy https://github.com/styliteag/haproxy-static-build/raw/main/dist/linux_amd64/haproxy-3.3.6Using curl (note the -L to follow GitHub's redirect to raw.githubusercontent.com):
# linux/amd64 — latest
curl -L -o haproxy https://github.com/styliteag/haproxy-static-build/raw/main/dist/linux_amd64/haproxy-latest
chmod +x haproxy
# linux/arm64 — latest
curl -L -o haproxy https://github.com/styliteag/haproxy-static-build/raw/main/dist/linux_arm64/haproxy-latest
chmod +x haproxy- Docker with Buildx and BuildKit enabled
- For multi-arch builds (e.g.
linux/arm64on anamd64host), QEMU binfmt registration is usually required (Docker Desktop provides this; on Linux you may needdocker run --privileged tonistiigi/binfmt --install allor similar)
From the repository root:
./build.shThis runs docker buildx build for linux/amd64 and linux/arm64, tags haproxy-static:3.3, and exports artifacts to ./dist (type=local). With multiple platforms, BuildKit usually writes one directory per platform (for example dist/linux_amd64/, dist/linux_arm64/), each containing the image root with the binary as haproxy-<version> (for example haproxy-3.3.6).
docker buildx build --platform linux/amd64 --output type=local,dest=./dist -t haproxy-static:3.3 .docker buildx build --platform linux/amd64 --load -t haproxy-static:3.3 .The final stage is based on scratch; the binary is installed as /haproxy-<version> (for example /haproxy-3.3.6), matching HAPROXY_VERSION.
Defaults are set in the Dockerfile as ARGs:
| Argument | Role |
|---|---|
ALPINE_VERSION |
Base image |
HAPROXY_VERSION |
HAProxy tarball |
OPENSSL_VERSION |
OpenSSL |
PCRE2_VERSION |
PCRE2 |
ZLIB_VERSION |
zlib |
Override at build time, for example:
docker buildx build --build-arg HAPROXY_VERSION=3.3.7 ...The build turns on OpenSSL, PCRE2 (static, with JIT), zlib, threading, and Prometheus exporter (USE_PROMEX=1). Adjust Makefile variables in the Dockerfile if you need a different feature set.
This project was written by a human with the help of AI tools.
AI tools (e.g. ChatGPT) were used as assistance for:
- brainstorming
- code suggestions
- debugging
All code was reviewed, adapted, and validated by the author.
Released under the MIT License.