Skip to content

Commit

Permalink
Fix: Always build on build platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
bokysan committed Jan 30, 2025
1 parent 085746e commit 29f5eb7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion postfix-exporter-01.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ index 75a22d8..81145c9 100644
@@ -1,8 +1,41 @@
-FROM scratch
+# syntax=docker/dockerfile:1.2
+FROM golang:1.23 AS builder
+FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
LABEL org.opencontainers.image.source="https://github.com/hsn723/postfix_exporter" \
org.opencontainers.image.authors="Hsn723" \
org.opencontainers.image.title="postfix_exporter"
Expand Down Expand Up @@ -38,6 +38,7 @@ index 75a22d8..81145c9 100644
+# Since we are checking out a specific SHA hash and we know this tests have worked previously, we are quite certain that the code will work.
+# Hence disabling the test here.
+# RUN go test
+RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM $TARGETOS/$TARGETARCH/$TARGETVARIANT"
+RUN env GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" GOARM="$( echo "$TARGETVARIANT" | grep -E -o "\\d+$")" go build -ldflags '-extldflags "-static"' -o /bin/postfix_exporter
+
+FROM scratch
Expand Down

0 comments on commit 29f5eb7

Please sign in to comment.