mirror of
https://github.com/livekit/livekit.git
synced 2026-11-04 06:57:29 +00:00
build: pin the builder stage to the host platform
The build already cross-compiles explicitly (CGO_ENABLED=0, GOOS=linux, GOARCH=$TARGETARCH), so the toolchain never needs to match the target arch. Without --platform=$BUILDPLATFORM a cross-arch build runs the entire Go compilation under QEMU emulation for a byte-identical binary: building linux/amd64 on an arm64 host went from minutes to still-running after ten. Only the final stage stays on $TARGETPLATFORM, where it belongs. go-version.sh reads the Go version out of the builder's FROM line, so its pattern now accepts an optional --platform flag before the image.
This commit is contained in:
1 parent
37901309a3
commit
a55d4c6c0f
2 files changed
+9
-3
No files matched your search
@@ -35,10 +35,10 @@ if [ ! -f "$dockerfile" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=$(sed -nE 's/^FROM[[:space:]]+golang:([0-9]+\.[0-9]+\.[0-9]+)[^[:space:]]*.*/\1/p' "$dockerfile" | sort -u)
|
||||
version=$(sed -nE 's/^FROM[[:space:]]+(--platform=[^[:space:]]+[[:space:]]+)?golang:([0-9]+\.[0-9]+\.[0-9]+)[^[:space:]]*.*/\2/p' "$dockerfile" | sort -u)
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
echo "$dockerfile: no pinned 'FROM golang:X.Y.Z-...' base image found" >&2
|
||||
echo "$dockerfile: no pinned 'FROM [--platform=...] golang:X.Y.Z-...' base image found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user