Reproducing multi-arch Go build performance in docker buildx
vs ko
https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
-
for buildx, add the
Dockerfile
- this is the "fully-optimized cross-compiling Go Dockerfile" from the above article, lightly adapted for the ko codebase
- no
go mod download
becauseko
repo usesvendor/
-
for ko, add the
.ko.yaml
- this defines a base image that consists of Distroless + Windows Nanoserver, for multi-arch and multi-OS builds
-
for my tests, I'm on a 2017 MBP
- 2.8 GHz Quad-Core Intel Core i7
- 16 GB 2133 MHz LPDDR3
- macOS 11.6.1 (20G224)
docker buildx build . --push -t gcr.io/imjasonh/ko-buildx \
--platform=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x
- NB: Windows builds didn't work at all for me, so I just excluded them
- cold cache: 208s
- code change: 32s
- no-op: 8s
- image:
gcr.io/imjasonh/ko-buildx@sha256:f112526706bd3197a594c45161f2a854741a8e21a73e8c88185f6674e004e9e5
ko publish --platform=all ./
- cold cache: 211s
- code change: 91s
- no-op: 59s
- image:
gcr.io/imjasonh/ko-ko/ko-98b8c7facdad74510a7cae0cd368eb4e@sha256:4d9166339f254f11b879257a7ebb5f5fa2cfa9c3d15f27ebb853c28c8d52d5be