Skip to content

Commit

Permalink
Fix: Fix building of Postfix exporter with newer version of Go and ot…
Browse files Browse the repository at this point in the history
…her architectures

Build should be faster now as well, as it's being built on the build
platform and not through QEMU.
  • Loading branch information
bokysan committed Oct 27, 2023
1 parent 2082f15 commit 335c7e9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-postfix-exporter/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ runs:
context: postfix_exporter
push: true
tags: '${{ inputs.tags }}'
platforms: "linux/386,linux/arm/v5,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/arm64,linux/ppc64le,linux/s390x"
platforms: "linux/386,linux/arm/v5,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/mips64le,linux/riscv64"
cache-from: type=local,src=/tmp/.buildx-cache/postfix-exporter,mode=max,compression=estargz
cache-to: type=local,dest=/tmp/.buildx-cache-new/postfix-exporter

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ jobs:
boky/postfix:edge-alpine
# linux/s390x: "rsyslog (no such package)"
# Latest Alpine does not have all the packages for 386 anymore. :-(
platforms: "linux/arm/v6,linux/arm/v7,linux/amd64,linux/arm64,linux/ppc64le"
# Latest Alpine does not have 'pandoc' in 'linux/arm/v7', which means SASL module cannot be built
platforms: "linux/arm/v6,linux/amd64,linux/arm64,linux/ppc64le"
cache-from: type=local,src=/tmp/.buildx-cache/alpine,mode=max,compression=estargz
cache-to: type=local,dest=/tmp/.buildx-cache-new/alpine
build-args: |
Expand Down
11 changes: 2 additions & 9 deletions helm/mail/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,13 @@ spec:
- name: {{ $fullName | quote }}
mountPath: {{ regexFind "^/?.*/" .Values.metrics.maillog | quote }}
subPath: logs
startupProbe:
exec:
command:
- sh
- -c
- >-
[ -f {{ .Values.metrics.maillog | quote }} ] && grep -qi "starting the Postfix mail system" {{ .Values.metrics.maillog | quote }}
failureThreshold: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: {{ .Values.metrics.path | quote }}
port: {{ .Values.metrics.port }}
initialDelaySeconds: 5
failureThreshold: 30
periodSeconds: 10
{{- end }}
{{- if .Values.extraContainers }}
{{- tpl .Values.extraContainers $root | nindent 8 }}
Expand Down
25 changes: 21 additions & 4 deletions postfix-exporter-01.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
diff --git a/Dockerfile b/Dockerfile
index a3327d8..ce8e22c 100644
index a3327d8..c082f5b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,7 +14,15 @@ COPY . .
@@ -1,4 +1,10 @@
-FROM golang:1.16 AS builder
+# syntax=docker/dockerfile:1.2
+FROM --platform=$BUILDPLATFORM golang:1.21 AS builder
+ARG TARGETPLATFORM
+ARG TARGETOS
+ARG TARGETARCH
+ARG TARGETVARIANT
+
WORKDIR /src

# avoid downloading the dependencies on succesive builds
@@ -14,10 +20,18 @@ COPY . .

# Force the go compiler to use modules
ENV GO111MODULE=on
-RUN go test
-RUN go build -o /bin/postfix_exporter
+# go test fails (sometimes) because it relies on an external dependency:
+#
+# warning: SASL authentication failure: cannot connect to saslauthd server: Permission denied
Expand All @@ -16,6 +29,10 @@ index a3327d8..ce8e22c 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 go build -o /bin/postfix_exporter
+RUN env GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=$TARGETVARIANT go build -ldflags '-extldflags "-static"' -o /bin/postfix_exporter

FROM debian:latest
-FROM debian:latest
+FROM scratch
EXPOSE 9154
WORKDIR /
COPY --from=builder /bin/postfix_exporter /bin/

0 comments on commit 335c7e9

Please sign in to comment.