From 55448794b2f47380edc00d251a5bcb27115a3d84 Mon Sep 17 00:00:00 2001 From: Peiman Jafari Date: Mon, 19 Feb 2024 21:05:55 -0800 Subject: [PATCH 1/3] ci: Fix multi-platform build --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08961e0..48e73f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM golang:1.21 as build +ARG TARGETPLATFORM +ARG BUILDPLATFORM +FROM --platform=${BUILDPLATFORM} golang:1.21 as build WORKDIR /go/artifactory_exporter ADD . /go/artifactory_exporter @@ -13,7 +15,8 @@ ARG SOURCE_BRANCH ARG BUILD_DATE ARG BUILD_USER -RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o /go/bin/artifactory_exporter -ldflags " \ + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(echo $TARGETPLATFORM | cut -d / -f2) go build -a -o /go/bin/artifactory_exporter -ldflags " \ -X github.com/prometheus/common/version.Version=${VERSION} \ -X github.com/prometheus/common/version.Revision=${SOURCE_COMMIT} \ -X github.com/prometheus/common/version.Branch=${SOURCE_BRANCH} \ From f5cffe10bea77d651327a42f88312f240f860126 Mon Sep 17 00:00:00 2001 From: Peiman Jafari Date: Mon, 19 Feb 2024 21:08:03 -0800 Subject: [PATCH 2/3] update --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48e73f9..91210e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ -ARG TARGETPLATFORM ARG BUILDPLATFORM -FROM --platform=${BUILDPLATFORM} golang:1.21 as build +FROM --platform=${BUILDPLATFORM} golang:1.21 AS build WORKDIR /go/artifactory_exporter ADD . /go/artifactory_exporter @@ -16,7 +15,9 @@ ARG BUILD_DATE ARG BUILD_USER -RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(echo $TARGETPLATFORM | cut -d / -f2) go build -a -o /go/bin/artifactory_exporter -ldflags " \ +ARG TARGETPLATFORM + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) go build -a -o /go/bin/artifactory_exporter -ldflags " \ -X github.com/prometheus/common/version.Version=${VERSION} \ -X github.com/prometheus/common/version.Revision=${SOURCE_COMMIT} \ -X github.com/prometheus/common/version.Branch=${SOURCE_BRANCH} \ From f7f54e1150ee43346c2b350065ca09ab67d011da Mon Sep 17 00:00:00 2001 From: Peiman Jafari Date: Mon, 19 Feb 2024 21:12:27 -0800 Subject: [PATCH 3/3] update --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91210e5..94cceaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -ARG BUILDPLATFORM -FROM --platform=${BUILDPLATFORM} golang:1.21 AS build +FROM golang:1.21 AS build WORKDIR /go/artifactory_exporter ADD . /go/artifactory_exporter