Feat: scratch docker build

This commit is contained in:
2026-06-01 21:51:38 +02:00
parent 8b60d3e280
commit 9fb9430319
2 changed files with 53 additions and 1 deletions
+40
View File
@@ -0,0 +1,40 @@
FROM alpine:3.22.4 AS builder
RUN apk add --no-cache \
ca-certificates \
gcc \
musl-dev \
make \
pkgconf \
curl-dev \
curl-static \
cjson-dev \
openssl-dev \
openssl-libs-static \
nghttp2-dev \
nghttp2-static \
zlib-dev \
zlib-static \
brotli-dev \
brotli-static \
c-ares-dev \
c-ares-static \
libidn2-dev \
libidn2-static \
libpsl-dev \
libpsl-static \
libunistring-dev \
libunistring-static
WORKDIR /build
COPY src/ src/
COPY Makefile .
RUN make STATIC=1
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /build/build/dns-keeper /dns-keeper
ENTRYPOINT ["/dns-keeper"]
+12
View File
@@ -66,3 +66,15 @@ The dynamically linked binary is smaller but requires dependencies:
libcurl, libcjson and pthread to be on the target machine. libcurl, libcjson and pthread to be on the target machine.
The static binary is slightly bigger but is fully self contained. The static binary is slightly bigger but is fully self contained.
### Docker Image
The [Dockerfile](./Dockerfile) in this repo builds a minimal image with just the static binary and CA certificates.
```sh
docker build -t dns-keeper .
```
> [!TIP]
> Because the image is just the c binary with ca certs, there is no shell to exec into.
> `docker exec` will not work for debugging.