Build the image's static binary with netgo, osusergo and sqlite_omit_load_extension (closes #525) #526

Merged
clawbot merged 1 commits from issue-525-static-build-tags into next 2026-10-13 10:43:47 +02:00
Collaborator

The image's static relink linked glibc's getaddrinfo (Go's cgo DNS resolver) and dlopen (SQLite extension loading). A static binary still needs glibc's shared libraries for both at run time, and the Alpine runtime has none. Closes #525.

  • Makefile: a GO_TAGS variable, empty by default, which the build target passes to go build as -tags, beside GO_LDFLAGS. A plain make build builds as before.
  • Dockerfile: the static relink sets GO_TAGS=netgo,osusergo,sqlite_omit_load_extension. The comment above it now says why, and no longer claims the earlier make build already verified compilation: with different tags the relink compiles different files.
  • README.md: the builder stage description names the tags.
  • internal/versionscript: the Makefile and Dockerfile content tests now expect -tags '$(GO_TAGS)' and the new relink line.

What the diff does not show:

  • The test and lint stages build without these tags, so the tagged binary is compiled only by the image's relink.
  • In the image, GODEBUG=netdns=cgo no longer selects the cgo resolver: Go logs that it ignores the setting and uses its own.
  • The relink is one long line because the Dockerfile test matches it as a single string.

Model: opus-5-5

The image's static relink linked glibc's `getaddrinfo` (Go's cgo DNS resolver) and `dlopen` (SQLite extension loading). A static binary still needs glibc's shared libraries for both at run time, and the Alpine runtime has none. Closes https://git.eeqj.de/sneak/webhooker/issues/525. - `Makefile`: a `GO_TAGS` variable, empty by default, which the build target passes to `go build` as `-tags`, beside `GO_LDFLAGS`. A plain `make build` builds as before. - `Dockerfile`: the static relink sets `GO_TAGS=netgo,osusergo,sqlite_omit_load_extension`. The comment above it now says why, and no longer claims the earlier `make build` already verified compilation: with different tags the relink compiles different files. - `README.md`: the builder stage description names the tags. - `internal/versionscript`: the Makefile and Dockerfile content tests now expect `-tags '$(GO_TAGS)'` and the new relink line. What the diff does not show: - The test and lint stages build without these tags, so the tagged binary is compiled only by the image's relink. - In the image, `GODEBUG=netdns=cgo` no longer selects the cgo resolver: Go logs that it ignores the setting and uses its own. - The relink is one long line because the Dockerfile test matches it as a single string. Model: opus-5-5
clawbot added the needs-review label 2026-10-13 10:21:21 +02:00
clawbot self-assigned this 2026-10-13 10:21:21 +02:00
clawbot added 1 commit 2026-10-13 10:21:21 +02:00
The image's static relink linked glibc's getaddrinfo (from Go's cgo DNS
resolver) and dlopen (from SQLite extension loading). A static binary
still needs glibc's shared libraries at run time for both, and the
Alpine runtime has none. The relink now passes the standard build tags
netgo, osusergo and sqlite_omit_load_extension through a GO_TAGS
variable, which the Makefile's build target hands to go build as -tags
next to GO_LDFLAGS, so the version stamp is composed as before.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 573f7f986a into next 2026-10-13 10:43:47 +02:00
clawbot deleted branch issue-525-static-build-tags 2026-10-13 10:43:48 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#526