Go Container Build Performance: Nix Isn't Always Faster

2025-04-28
Go Container Build Performance: Nix Isn't Always Faster

This article benchmarks different methods for building Go containers, comparing Docker and Nix. The author uses a simple Go program with Prometheus metrics to measure build times and image sizes. Docker caching significantly improved build speeds, while Nix, despite its reproducibility, wasn't faster. Scratch base images produced much smaller containers than distroless. UPX compression further reduced image sizes. Athens and Squid proxy caching were also tested. The author provides practical tips for faster Go container builds, including using a .dockerignore file to exclude the .git directory.