Skip to content

Commit e69445e

Browse files
committed
Build for more platforms
1 parent ed17e0f commit e69445e

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- main
1212

1313
env:
14-
DOCKER_PLATFORMS: "linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/mips64le,linux/386"
14+
DOCKER_PLATFORMS: "linux/arm/v5,linux/arm/v6,linux/arm/v7,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/mips64le,linux/386,linux/riscv64,linux/mips64"
1515

1616
concurrency:
1717
group: ${{ github.ref_name }}-ci
@@ -51,6 +51,11 @@ jobs:
5151
packages: write # for docker/build-push-action to push to GHCR
5252
issues: write # for goreleaser/goreleaser-action to close milestones
5353
needs: unit-tests
54+
services:
55+
registry:
56+
image: registry:2
57+
ports:
58+
- 5000:5000
5459
steps:
5560
- name: Checkout Repository
5661
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -64,8 +69,6 @@ jobs:
6469

6570
- name: Setup QEMU
6671
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
67-
with:
68-
platforms: arm,arm64,ppc64le,s390x,mips64le,386
6972
if: github.event_name != 'pull_request'
7073

7174
- name: Docker Buildx
@@ -114,10 +117,11 @@ jobs:
114117
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
115118
with:
116119
images: |
117-
nginx/nginx-prometheus-exporter
118-
ghcr.io/nginxinc/nginx-prometheus-exporter
119-
public.ecr.aws/nginx/nginx-prometheus-exporter
120-
quay.io/nginx/nginx-prometheus-exporter
120+
name=nginx/nginx-prometheus-exporter,enable=${{ github.event_name != 'pull_request' }}
121+
name=ghcr.io/nginxinc/nginx-prometheus-exporter,enable=${{ github.event_name != 'pull_request' }}
122+
name=public.ecr.aws/nginx/nginx-prometheus-exporter,enable=${{ github.event_name != 'pull_request' }}
123+
name=quay.io/nginx/nginx-prometheus-exporter,enable=${{ github.event_name != 'pull_request' }}
124+
name=localhost:5000/nginx/nginx-prometheus-exporter
121125
tags: |
122126
type=edge
123127
type=ref,event=pr
@@ -175,7 +179,7 @@ jobs:
175179
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
176180
with:
177181
version: v2.2.0 # renovate: datasource=github-tags depName=goreleaser/goreleaser
178-
args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --clean
182+
args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean
179183
env:
180184
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
181185
NGINX_GITHUB_TOKEN: ${{ secrets.NGINX_PAT }}
@@ -192,23 +196,22 @@ jobs:
192196
file: build/Dockerfile
193197
context: "."
194198
target: goreleaser
195-
platforms: ${{ github.event_name != 'pull_request' && env.DOCKER_PLATFORMS || '' }}
199+
platforms: ${{ env.DOCKER_PLATFORMS }}
196200
tags: ${{ steps.meta.outputs.tags }}
197201
labels: ${{ steps.meta.outputs.labels }}
198-
annotations: ${{ github.event_name != 'pull_request' && steps.meta.outputs.annotations || '' }}
199-
load: ${{ github.event_name == 'pull_request' }}
200-
push: ${{ github.event_name != 'pull_request' }}
202+
annotations: ${{ steps.meta.outputs.annotations }}
203+
push: true
201204
cache-from: type=gha
202205
cache-to: type=gha,mode=max
203-
provenance: ${{ github.event_name != 'pull_request' && 'mode=max' || 'false' }}
204-
sbom: ${{ github.event_name != 'pull_request' }}
206+
provenance: mode=max
207+
sbom: true
205208

206209
- name: Scan image
207210
uses: anchore/scan-action@64a33b277ea7a1215a3c142735a1091341939ff5 # v4.1.2
208211
id: scan
209212
continue-on-error: true
210213
with:
211-
image: nginx/nginx-prometheus-exporter:${{ steps.meta.outputs.version }}
214+
image: localhost:5000/nginx/nginx-prometheus-exporter:${{ steps.meta.outputs.version }}
212215
only-fixed: true
213216
add-cpes-if-none: true
214217

.goreleaser.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ builds:
88
- env:
99
- CGO_ENABLED=0
1010
goos:
11-
- linux
1211
- darwin
12+
- freebsd
13+
- linux
14+
- solaris
1315
- windows
1416
goarch:
1517
- 386
1618
- amd64
1719
- arm
1820
- arm64
19-
- ppc64le
21+
- mips64
2022
- mips64le
23+
- ppc64
24+
- ppc64le
25+
- riscv64
2126
- s390x
2227
goarm:
2328
- 5
@@ -89,9 +94,6 @@ announce:
8994
milestones:
9095
- close: true
9196

92-
snapshot:
93-
name_template: "edge"
94-
9597
snapcrafts:
9698
- name_template: "{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
9799
title: NGINX Prometheus Exporter

build/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
# syntax=docker/dockerfile:1.9
2-
FROM golang:1.23 AS base
2+
FROM golang:1.23-alpine AS builder
33
ARG VERSION
44
ARG TARGETARCH
55

66
WORKDIR /go/src/github.com/nginxinc/nginx-prometheus-exporter
77

8-
FROM base AS builder
98
COPY --link go.mod go.sum ./
109
RUN go mod download
10+
1111
COPY --link *.go ./
1212
COPY --link collector ./collector
1313
COPY --link client ./client
14+
1415
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -trimpath -a -ldflags "-s -w -X main.version=${VERSION}" -o nginx-prometheus-exporter .
1516

1617

18+
FROM --platform=$BUILDPLATFORM alpine:3.20 AS certs
19+
1720
FROM scratch AS intermediate
18-
COPY --from=base --link /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
21+
COPY --from=certs --link /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
1922
USER 1001:1001
2023
ENTRYPOINT [ "/usr/bin/nginx-prometheus-exporter" ]
2124

@@ -32,4 +35,4 @@ ARG TARGETPLATFORM
3235
LABEL org.nginx.exporter.image.build.target="${TARGETPLATFORM}"
3336
LABEL org.nginx.exporter.image.build.version="goreleaser"
3437

35-
COPY --link dist/nginx-prometheus-exporter_linux_$TARGETARCH${TARGETVARIANT:+_7}*/nginx-prometheus-exporter /usr/bin/
38+
COPY --link dist/nginx-prometheus-exporter_linux_$TARGETARCH${TARGETVARIANT/v/_}*/nginx-prometheus-exporter /usr/bin/

0 commit comments

Comments
 (0)