From faa59b826126826b23f215cdad92f0e634ecb027 Mon Sep 17 00:00:00 2001 From: Qasim Mehmood <18313886+ThisIsQasim@users.noreply.github.com> Date: Wed, 25 Feb 2026 15:30:21 +0500 Subject: [PATCH] Faster multi stage build using cross compilation (#72) Co-authored-by: maddie --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1e221b5..5a53cff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -FROM golang:1.18-alpine AS build_base +FROM --platform=$BUILDPLATFORM golang:1.18-alpine AS build_base RUN apk add --no-cache git gcc ca-certificates libc-dev WORKDIR /build COPY go.mod go.sum ./ RUN go mod download COPY ./ ./ + ENV CGO_ENABLED=0 -RUN go build -ldflags "-w -s" -trimpath -o speedtest . +ARG TARGETOS TARGETARCH +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-w -s" -trimpath -buildvcs=false -o speedtest . FROM scratch WORKDIR /app