Hasty Briefsbeta

Bilingual

Building Small Go Containers?

a year ago
  • #containerization
  • #golang
  • #performance
  • The repo demonstrates different methods for building containers and measures their performance.
  • Nix is explored for speeding up builds but found to be slow despite being repeatable.
  • The example program includes a loop printing a counter and Prometheus counters.
  • Additional libraries (database/sql, clickhouse-go, pyroscope-go, go-redis/v9) were added to test performance.
  • Scratch containers are found to be smaller than distroless, questioning the latter's recommendation.
  • UPX usage is tested without issues on amd64, but potential issues on Apple machines are noted.
  • Build summaries show time, size, and layers for various container builds.
  • Tips for improving Golang container build times include avoiding copying .git and using Docker cache.
  • Athens proxy is suggested for caching modules in CI/CD environments.
  • A validator tool is used to ensure containers work correctly by checking print loops and Prometheus counters.
  • Squid proxy is deployed for testing HTTP cache, though its effectiveness is limited by HTTPS.
  • Nix builds are compared with Docker builds, showing Nix's caching benefits.