All posts

Shipping a portfolio as a single Go binary

  • #go
  • #sqlite
  • #devops

Deploying a website shouldn’t require a dozen moving parts. This site is a single Go binary.

The ingredients

  1. embed bundles templates and static files into the binary.
  2. modernc.org/sqlite is a pure-Go SQLite driver, so CGO_ENABLED=0 works and cross-compiling is trivial.
  3. html/template renders 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.

Nahid Hasan
Nahid Hasan

I build backend services and APIs in Go, and the security platforms that run on them: SIEM/XDR, detection and threat intelligence.

Get in touch