From 89b3fdd74cc1722248eeab9be56fd0f0558bd644 Mon Sep 17 00:00:00 2001 From: maskpp Date: Wed, 12 Jun 2024 15:13:40 +0800 Subject: [PATCH] build using cross-compilation (#274) --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7f9981251d..2dfb6758f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG VERSION="" ARG BUILDNUM="" # Build Geth in a stock Go builder container -FROM golang:1.21-alpine as builder +FROM --platform=${BUILDPLATFORM} golang:1.21-alpine as builder RUN apk add --no-cache gcc musl-dev linux-headers git @@ -14,7 +14,9 @@ COPY go.sum /go-ethereum/ RUN cd /go-ethereum && go mod download ADD . /go-ethereum -RUN --mount=type=cache,target=/root/.cache/go-build,sharing=locked \ +ARG TARGETOS +ARG TARGETARCH +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ cd /go-ethereum && go run build/ci.go install -static ./cmd/geth # Pull Geth into a second stage deploy alpine container