From 7331dc2394d3e92881b6a12f929b05676cea9d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 5 Nov 2023 13:17:47 +0100 Subject: [PATCH] Add cross OS Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- Dockerfile.cross | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile.cross diff --git a/Dockerfile.cross b/Dockerfile.cross new file mode 100644 index 00000000..e8e48c65 --- /dev/null +++ b/Dockerfile.cross @@ -0,0 +1,22 @@ +# Build this Docker Image on any platform with +# docker buildx build -t a --platform=windows/amd64 . + +ARG BASE=mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0 + +FROM --platform=$BUILDPLATFORM golang:1.21 as builder +ARG TARGETARCH +ARG TARGETOS + +# Get dependencies +WORKDIR /w +COPY go.mod go.sum ./ +RUN go mod download +RUN go install github.com/prometheus/promu@latest + +# Build windows_exporter +COPY . ./ +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make windows_exporter.exe + +FROM $BASE +COPY --from=builder /w/windows_exporter.exe /windows_exporter.exe +ENTRYPOINT ["windows_exporter.exe"]