diff --git a/Dockerfile b/Dockerfile index a5fc902..ff75be0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,10 @@ -FROM docker.io/golang:1.22-alpine3.20 AS builder +FROM --platform=$BUILDPLATFORM docker.io/golang:1.22-alpine3.20 AS builder + +ARG TARGETARCH ENV CGO_ENABLED=0 \ - GOOS=linux + GOOS=linux \ + GOARCH=$TARGETARCH WORKDIR /src diff --git a/Makefile b/Makefile index 81f56c1..a27f28e 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,20 @@ VERSION=latest BRANCH := $(shell git rev-parse --abbrev-ref HEAD) IMAGE_NAME=$(DOCKER_REGISTRY)/radix-cost-allocation:$(BRANCH)-$(VERSION) +.PHONY: build build: docker build -t $(IMAGE_NAME) . -push: +.PHONY: push +push: build az acr login -n $(DOCKER_REGISTRY) docker push $(IMAGE_NAME) +.PHONY: pushmultiplatform +pushmultiplatform: + az acr login -n $(DOCKER_REGISTRY) + docker buildx build --platform=linux/amd64,linux/arm64 -t $(IMAGE_NAME) --push . + .PHONY: test test: go test -cover `go list ./...`