From db2b4918e283034f9b3cf93b2f379eaf92032504 Mon Sep 17 00:00:00 2001 From: Jonas Thelemann Date: Tue, 11 Apr 2023 14:15:39 +0200 Subject: [PATCH] docker: Correct multi platform build for ARM (#936) --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 35e4347..96b277f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20.2-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.20.2-alpine AS builder WORKDIR /go/src/github.com/tus/tusd # Add gcc and libc-dev early so it is cached @@ -19,8 +19,12 @@ COPY pkg/ ./pkg/ ARG GIT_VERSION ARG GIT_COMMIT +# Get the operating system and architecture to build for +ARG TARGETOS +ARG TARGETARCH + RUN set -xe \ - && GOOS=linux GOARCH=amd64 go build \ + && GOOS=$TARGETOS GOARCH=$TARGETARCH go build \ -ldflags="-X github.com/tus/tusd/cmd/tusd/cli.VersionName=${GIT_VERSION} -X github.com/tus/tusd/cmd/tusd/cli.GitCommit=${GIT_COMMIT} -X 'github.com/tus/tusd/cmd/tusd/cli.BuildDate=$(date --utc)'" \ -o /go/bin/tusd ./cmd/tusd/main.go