Compare commits

..

No commits in common. "a99abca1651fb8843f66ba7604846c5b9efbd7ae" and "12708dc8c78f333d17ca314c96977ff1623f4589" have entirely different histories.

4 changed files with 36 additions and 25 deletions

View file

@ -19,9 +19,9 @@ runs:
- name: Checkout
uses: actions/checkout@v4
with:
repository: kumina/postfix_exporter
repository: Hsn723/postfix_exporter # Hsn723 repo is actually being updated
path: 'postfix_exporter'
ref: 'a6f58e9b2b2b4decc7e65c5a34b4fd53cd6665f1' # Latest commit we know that works
ref: 'v0.7.0' # Latest commit we know that works
- name: Apply patches
shell: bash
@ -68,8 +68,8 @@ runs:
push: true
tags: '${{ inputs.tags }}'
labels: ${{ steps.meta.outputs.labels }}
platforms: "linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8,linux/mips64le"
#platforms: "linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8,linux/mips64le,linux/ppc64le,linux/s390x"
platforms: "linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/mips64le,linux/ppc64le,linux/s390x"
# linux/386,linux/arm/v6,linux/arm64,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

View file

@ -7,7 +7,7 @@
#
# - use Alpine if you're strapped for space. But beware it uses MUSL LIBC, so unicode support might be an issue.
# - use Debian if you're interested in the greatest cross-platform compatibility. It is larger than Alpine, though.
# - use Ubuntu if, well, Ubuntu is your thing and you're used to the buntu ecosystem.
# - use Ubuntu if, well, Ubuntu is your thing and you're used to Ubuntu ecosystem.
ARG BASE_IMAGE=debian:bookworm-slim
FROM ${BASE_IMAGE} AS build-scripts
@ -32,7 +32,7 @@ FROM base AS sasl
ARG TARGETPLATFORM
ARG SASL_XOAUTH2_REPO_URL=https://github.com/tarickb/sasl-xoauth2.git
ARG SASL_XOAUTH2_GIT_REF=release-0.25
ARG SASL_XOAUTH2_GIT_REF=release-0.26
# --mount=type=cache,target=/var/cache/apk,sharing=locked,id=var-cache-apk-$TARGETPLATFORM \
# --mount=type=cache,target=/etc/apk/cache,sharing=locked,id=etc-apk-cache-$TARGETPLATFORM \

View file

@ -131,7 +131,7 @@ Several potentially "surprising" changes went into this issue and hence warrant
- **[`master`](https://github.com/bokysan/docker-postfix/tree/master/) branch now builds images called [`edge`](https://hub.docker.com/r/boky/postfix/tags?page=1&name=edge)**.
`latest` images are built from the last tag. We've had several issues with people using the `latest` tag
and reporting problems. You can now rely on `latest` being the latest stable release.
- Image now builds its own version of [postfix-exporter](https://github.com/kumina/postfix_exporter) and relies on this
- Image now builds its own version of [postfix-exporter](https://github.com/hsn723/postfix_exporter) and relies on this
third-party project. Checkout is from master branch, based
on specific SHA commit id. The same hash is used for master and tags.
- **Architecture galore!** With the addition of debian images, we now support support more architectures than ever. The list includes:

View file

@ -1,25 +1,34 @@
diff --git a/Dockerfile b/Dockerfile
index a3327d8..1cdfa84 100644
index 75a22d8..81145c9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,10 @@
-FROM golang:1.16 AS builder
@@ -1,8 +1,41 @@
-FROM scratch
+# syntax=docker/dockerfile:1.2
+FROM golang:1.21.3-bookworm AS builder
+FROM 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"
+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
+WORKDIR /src
+
+# avoid downloading the dependencies on successive builds
+RUN apt-get update -qq && apt-get install -qqy \
+ build-essential \
+ libsystemd-dev
+
+COPY go.mod go.sum ./
+RUN go mod download
+RUN go mod verify
+
+COPY . .
+
+# Force the go compiler to use modules
+ENV GO111MODULE=on
+# go test fails (sometimes) because it relies on an external dependency:
+#
+# warning: SASL authentication failure: cannot connect to saslauthd server: Permission denied
@ -30,10 +39,12 @@ index a3327d8..1cdfa84 100644
+# Hence disabling the test here.
+# RUN go test
+RUN env GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" GOARM="$( echo "$TARGETVARIANT" | grep -E -o "\\d+$")" go build -ldflags '-extldflags "-static"' -o /bin/postfix_exporter
-FROM debian:latest
+
+FROM scratch
EXPOSE 9154
WORKDIR /
COPY --from=builder /bin/postfix_exporter /bin/
-COPY postfix_exporter /
-COPY LICENSE /
-ENTRYPOINT ["/postfix_exporter"]
+WORKDIR /
+COPY --from=builder /bin/postfix_exporter /bin/
+ENTRYPOINT ["/bin/postfix_exporter"]