From a913fde9516d649085ba7b977fbc46e3790b0ea8 Mon Sep 17 00:00:00 2001 From: Jeev B Date: Wed, 12 Apr 2023 10:56:43 -0700 Subject: [PATCH] Enable multiarch build and infer GOOS and GOARCH from environment (#57) * Enable multiarch build and infer GOOS and GOARCH from environment Signed-off-by: Jeev B * fix copy pasta Signed-off-by: Jeev B --------- Signed-off-by: Jeev B --- Dockerfile | 7 ++++++- Makefile | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 64a4236..2909cfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,12 @@ # # TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst -FROM golang:1.18-alpine3.16 as builder +FROM --platform=${BUILDPLATFORM} golang:1.18-alpine3.16 as builder + +ARG TARGETARCH +ENV GOARCH "${TARGETARCH}" +ENV GOOS linux + RUN apk add git openssh-client make curl # COPY only the go mod files for efficient caching diff --git a/Makefile b/Makefile index 1763fff..21324a0 100755 --- a/Makefile +++ b/Makefile @@ -11,8 +11,10 @@ clean: rm -rf bin .PHONY: linux_compile +linux_compile: export CGO_ENABLED ?= 0 +linux_compile: export GOOS ?= linux linux_compile: - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /artifacts/flyte-copilot . + go build -o /artifacts/flyte-copilot . .PHONY: compile compile: