Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
1 / 5
0

Cross-Compiling Go for Alpine vs Distroless: The CGO_ENABLED Decision Tree

DEV Community·Gabriel Anhaia·25 days ago
#RI0qJuA4
#question#cgorequired#go#binary#build#alpine
Reading 0:00
15s threshold

Book: Hexagonal Architecture in Go Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub You've seen this one. The CI green-lights the build. The image pushes. The pod boots. And then the first request to an external service hangs for thirty seconds and times out with a DNS error that contradicts what nslookup inside the container just told you. The pod is on Alpine. The binary was built with CGO_ENABLED=1 on Debian. The C runtime that compiled it was glibc. The C runtime trying to run it is musl. They are not the same runtime, and Go's net package quietly notices. The decision tree behind that one line in your Dockerfile, CGO_ENABLED=0 or CGO_ENABLED=1 , decides whether you can ship to Alpine, to distroless, or to scratch.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More