Skip to content

Commit a407d55

Browse files
committed
Add SBOMs for Docker images
1 parent 05231dd commit a407d55

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

.github/workflows/ci.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
steps:
3232
- name: Checkout Repository
3333
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
34+
3435
- name: Setup Golang Environment
3536
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
3637
with:
@@ -42,26 +43,30 @@ jobs:
4243
build-docker:
4344
name: Build Docker Image
4445
runs-on: ubuntu-22.04
45-
needs: [unit-tests]
46+
needs: unit-tests
4647
steps:
4748
- name: Checkout Repository
4849
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
4950
with:
5051
fetch-depth: 0
52+
5153
- name: Setup Golang Environment
5254
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
5355
with:
5456
go-version-file: go.mod
5557
cache: true
58+
5659
- name: Determine GOPATH
5760
id: go
5861
run: |
5962
echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
6063
- name: Setup QEMU
64+
6165
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
6266
with:
6367
platforms: arm,arm64,ppc64le,s390x,mips64le,386
6468
if: github.event_name != 'pull_request'
69+
6570
- name: Docker Buildx
6671
uses: docker/setup-buildx-action@f03ac48505955848960e80bbb68046aa35c7b9e7 # v2.4.1
6772
- name: DockerHub Login
@@ -70,27 +75,31 @@ jobs:
7075
username: ${{ secrets.DOCKER_USERNAME }}
7176
password: ${{ secrets.DOCKER_PASSWORD }}
7277
if: github.event_name != 'pull_request'
78+
7379
- name: Login to GitHub Container Registry
7480
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
7581
with:
7682
registry: ghcr.io
7783
username: ${{ github.repository_owner }}
7884
password: ${{ secrets.GITHUB_TOKEN }}
7985
if: github.event_name != 'pull_request'
86+
8087
- name: Login to Public ECR
8188
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
8289
with:
8390
registry: public.ecr.aws
8491
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
8592
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
8693
if: github.event_name != 'pull_request'
94+
8795
- name: Login to Quay.io
8896
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
8997
with:
9098
registry: quay.io
9199
username: ${{ secrets.QUAY_USERNAME }}
92100
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
93101
if: github.event_name != 'pull_request'
102+
94103
- name: Docker meta
95104
id: meta
96105
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
@@ -108,15 +117,18 @@ jobs:
108117
type=semver,pattern={{major}}.{{minor}}
109118
labels: |
110119
org.opencontainers.image.vendor=NGINX Inc <[email protected]>
120+
111121
- name: Publish Release Notes
112122
uses: release-drafter/release-drafter@cfc5540ebc9d65a8731f02032e3d44db5e449fb6 # v5.22.0
113123
with:
114124
publish: true
115125
env:
116126
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117127
if: ${{ startsWith(github.ref, 'refs/tags/') }}
128+
118129
- name: Download Syft
119130
uses: anchore/sbom-action/download-syft@07978da4bdb4faa726e52dfc6b1bed63d4b56479 # v0.13.3
131+
120132
- name: Run GoReleaser
121133
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
122134
with:
@@ -127,7 +139,8 @@ jobs:
127139
GOPATH: ${{ steps.go.outputs.go_path }}
128140
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.NGINX_PAT }}
129141
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_COMMUNITY }}
130-
- name: Push to Dockerhub
142+
143+
- name: Build and Push Docker Image
131144
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
132145
with:
133146
file: build/Dockerfile
@@ -140,3 +153,5 @@ jobs:
140153
push: ${{ github.event_name != 'pull_request' }}
141154
cache-from: type=gha
142155
cache-to: type=gha,mode=max
156+
provenance: false
157+
sbom: ${{ github.event_name != 'pull_request' }}

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,23 @@ The binary is built with the name `nginx-prometheus-exporter`.
341341
## Grafana Dashboard
342342
The official Grafana dashboard is provided with the exporter for NGINX. Check the [Grafana Dashboard](./grafana/README.md) documentation for more information.
343343
344+
## SBOM (Software Bill of Materials)
345+
346+
We generate SBOMs for the binaries and the Docker image.
347+
348+
### Binaries
349+
350+
The SBOMs for the binaries are available in the releases page. The SBOMs are generated using [syft](https://github.com/anchore/syft) and are available in SPDX format.
351+
352+
### Docker Image
353+
354+
The SBOM for the Docker image is available in the [DockerHub](https://hub.docker.com/r/nginx/nginx-prometheus-exporter), [GitHub Container registry](https://github.com/nginxinc/nginx-prometheus-exporter/pkgs/container/nginx-prometheus-exporter), [Amazon ECR Public Gallery](https://gallery.ecr.aws/nginx/nginx-prometheus-exporter) and [Quay.io](https://quay.io/repository/nginx/nginx-prometheus-exporter) repositories. The SBOMs are generated using [syft](https://github.com/anchore/syft) and stored as an attestation in the image manifest.
355+
356+
For example to retrieve the SBOM for `linux/amd64` from Docker Hub and analyze it using [grype](https://github.com/anchore/grype) you can run the following command:
357+
```
358+
$ docker buildx imagetools inspect nginx/nginx-prometheus-exporter:edge --format '{{ json (index .SBOM "linux/amd64").SPDX }}' | grype
359+
```
360+
344361
## Contacts
345362
346363
We’d like to hear your feedback! If you have any suggestions or experience issues with the NGINX Prometheus Exporter, please create an issue or send a pull request on GitHub.

build/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# syntax=docker/dockerfile:1.4
1+
# syntax=docker/dockerfile:1.5
22
FROM golang:1.20 as base
33
ARG VERSION
44
ARG TARGETARCH

0 commit comments

Comments
 (0)