All posts
Shipping a portfolio as a single Go binary
Deploying a website shouldn’t require a dozen moving parts. This site is a single Go binary.
The ingredients
embedbundles templates and static files into the binary.modernc.org/sqliteis a pure-Go SQLite driver, soCGO_ENABLED=0works and cross-compiling is trivial.html/templaterenders pages on the server, which means a fast first paint and great SEO.
Deploying
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o portfolio .
scp portfolio server:/opt/portfolio/
That’s it. The database file is created on first run.