From c45310dc9e503579341af6d53523360c77272c1f Mon Sep 17 00:00:00 2001 From: sneak Date: Sun, 4 Oct 2026 04:31:36 +0000 Subject: [PATCH] Build a static binary so the scratch image runs (closes #126) The final stage is scratch, which has no C library, but the builder compiled mfer with cgo on (the golang image's default). google/uuid imports net, so the binary came out dynamically linked and the image could not start. The image's go build now sets CGO_ENABLED=0; nothing in mfer needs cgo. A new builder step runs ldd on the binary and fails the build unless it reports a static executable. Model: opus-5-5 --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 860967f..3f24a9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,7 +67,10 @@ RUN version="${VERSION:-$(git describe --tags --always)}"; \ exit 1; \ fi; \ cd cmd/mfer && \ - go build -tags urfave_cli_no_docs -ldflags "-X main.Gitrev=$version" -o /mfer . + CGO_ENABLED=0 go build -tags urfave_cli_no_docs -ldflags "-X main.Gitrev=$version" -o /mfer . + +# Fail unless /mfer is statically linked: scratch has no C library to run it. +RUN ldd /mfer 2>&1 | grep -q 'not a dynamic executable' FROM scratch COPY --from=builder /mfer /mfer