From 97a6aa4e8c91a570ae480a2060402d54508e1ae1 Mon Sep 17 00:00:00 2001 From: Jeev B Date: Wed, 12 Apr 2023 10:43:59 -0700 Subject: [PATCH] Infer GOOS and GOARCH from environment (#550) * Infer GOOS and GOARCH from environment Signed-off-by: Jeev B * Multiarch builds for flytescheduler Signed-off-by: Jeev B * fix makefile to read variables from environment and overrides Signed-off-by: Jeev B --------- Signed-off-by: Jeev B --- .github/workflows/checks.yml | 1 - Makefile | 13 +++++++++---- scheduler.Dockerfile | 7 ++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4c3931700..65c257367 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -71,7 +71,6 @@ jobs: FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} FLYTE_BOT_USERNAME: ${{ secrets.FLYTE_BOT_USERNAME }} - push-docker-image-flytescheduler: name: Build & Push Flytescheduler Image needs: [ bump_version ] diff --git a/Makefile b/Makefile index 9b80b7030..df3dcd379 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,10 @@ docker_build_scheduler: docker build -t $$FLYTE_SCHEDULER_REPOSITORY:$(GIT_HASH) -f Dockerfile.scheduler . .PHONY: integration +integration: export CGO_ENABLED ?= 0 +integration: export GOFLAGS ?= -count=1 integration: - CGO_ENABLED=0 GOFLAGS="-count=1" go test -v -tags=integration ./tests/... + go test -v -tags=integration ./tests/... .PHONY: k8s_integration k8s_integration: @@ -51,12 +53,16 @@ compile_scheduler_debug: .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/flyteadmin -ldflags=$(LD_FLAGS) ./cmd/ + go build -o /artifacts/flyteadmin -ldflags=$(LD_FLAGS) ./cmd/ .PHONY: linux_compile_scheduler +linux_compile_scheduler: export CGO_ENABLED ?= 0 +linux_compile_scheduler: export GOOS ?= linux linux_compile_scheduler: - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /artifacts/flytescheduler -ldflags=$(LD_FLAGS) ./cmd/scheduler/ + go build -o /artifacts/flytescheduler -ldflags=$(LD_FLAGS) ./cmd/scheduler/ .PHONY: server @@ -77,4 +83,3 @@ seed_projects: go run cmd/main.go migrate seed-projects project admintests flytekit --server.kube-config ~/.kube/config --config flyteadmin_config.yaml all: compile - diff --git a/scheduler.Dockerfile b/scheduler.Dockerfile index 3e79e5c20..35753d84b 100644 --- a/scheduler.Dockerfile +++ b/scheduler.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.15 as builder +FROM --platform=${BUILDPLATFORM} golang:1.18-alpine3.15 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