Skip to content

Commit

Permalink
trying to pass targetarch var from dockerfile to makefile (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasthuen authored Oct 4, 2024
1 parent 3597b4f commit 1dec525
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ ARG GO_VERSION=1.23.1
# -------
# Builder
# -------
FROM golang:${GO_VERSION} AS base_builder
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS base_builder
ARG PACKAGE
ARG TARGETOS
ARG TARGETARCH

WORKDIR /go/src/${PACKAGE}
ADD go.mod go.sum /go/src/${PACKAGE}/
Expand All @@ -20,7 +22,7 @@ ARG BUILD_SUB_TARGET
WORKDIR /go/src/${PACKAGE}

ADD . .
RUN GIT_TAG=${VCS_REF} make build${BUILD_SUB_TARGET}
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} GIT_TAG=${VCS_REF} make build${BUILD_SUB_TARGET}


# ------------
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ KEYVAULT_ENV_BINARY_NAME=azure-keyvault-env

DOCKER_INTERNAL_REG:=akv2k8s.azurecr.io
DOCKER_INTERNAL_URL:=akv2k8s.azurecr.io
DOCKER_INTERNAL_USER:=
DOCKER_INTERNAL_USER:=akv2k8s
DOCKER_INTERNAL_PASSW:=
DOCKER_RELEASE_REG:=spvest
DOCKER_RELEASE_URL:=registry-1.docker.io
Expand All @@ -33,6 +33,7 @@ DOCKER_RELEASE_TAG_VAULTENV := $(shell echo $(DOCKER_RELEASE_TAG) | sed s/"vault

TAG=
GOOS ?= linux
GOARCH ?= amd64
TEST_GOOS ?= linux

BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
Expand Down Expand Up @@ -174,7 +175,7 @@ init-int-test-local:
int-test-local: init-int-test-local test

bin/%:
GOOS=$(GOOS) GOARCH=amd64 go build $(GO_BUILD_OPTIONS) -o "$(@)" "$(PKG_NAME)"
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GO_BUILD_OPTIONS) -o "$(@)" "$(PKG_NAME)"

.PHONY: clean
clean:
Expand Down

0 comments on commit 1dec525

Please sign in to comment.