This adds the -s linker flag when building the go binary (to strip debug symbols) which shaves off ~2MB of the resulting code. Additionally, it runs the binary output through an aggressive upx run. Here are the resulting Docker image sizes (which are pretty much just the sizes of the binaries in the scratch container).
Roughly they're all ~30% of the previous size but with a slight startup penalty (likely in the single milliseconds or lower) due to upx and the need to decompress the binary code sections in memory.
This adds the
-s
linker flag when building the go binary (to strip debug symbols) which shaves off ~2MB of the resulting code. Additionally, it runs the binary output through an aggressive upx run. Here are the resulting Docker image sizes (which are pretty much just the sizes of the binaries in the scratch container).Roughly they're all ~30% of the previous size but with a slight startup penalty (likely in the single milliseconds or lower) due to
upx
and the need to decompress the binary code sections in memory.