From 4f6ad0afbcb2c8a4de0c6aa4d41c99e9c19eac14 Mon Sep 17 00:00:00 2001 From: maskpp Date: Thu, 13 Jun 2024 00:16:15 +0800 Subject: [PATCH] build using cross-compilation --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 63b92e0825..05d45b24f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG VERSION="" ARG BUILDNUM="" # Build Geth in a stock Go builder container -FROM golang:1.22-alpine as builder +FROM --platform=${BUILDPLATFORM} golang:1.22-alpine as builder RUN apk add --no-cache gcc musl-dev linux-headers git @@ -14,7 +14,11 @@ COPY go.sum /go-ethereum/ RUN cd /go-ethereum && go mod download ADD . /go-ethereum -RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth +# Build using cross-compilation +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 FROM alpine:latest