Skip to content

Commit c2de741

Browse files
committed
use distroless, but scan intermediate step
1 parent 9996a84 commit c2de741

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

.github/workflows/build-and-release.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,30 @@ jobs:
6565
echo "::error::CodeQL produced ${count} alerts (warning/error)."
6666
exit 1
6767
fi
68+
scan-intermediate-image:
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Scan intermediate image with grype
72+
id: scan
73+
uses: anchore/scan-action@f6601287cdb1efc985d6b765bbf99cb4c0ac29d8 # v7.0.0
74+
continue-on-error: true
75+
with:
76+
cache-db: true
77+
image: "alpine:3.22.2" # sync this with Containerfile
78+
output-file: grype.sarif
79+
severity-cutoff: high
80+
- name: Upload SARIF file
81+
uses: github/codeql-action/upload-sarif@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
82+
with:
83+
sarif_file: grype.sarif
84+
- name: Check success or failure
85+
if: ${{ steps.scan.outcome == 'failure' }}
86+
run: |-
87+
jq '.runs[0].results | map(select(.level == "error"))' grype.sarif
88+
exit 1
6889
6990
build-go:
70-
needs: [ scan-dependencies, scan-codeql ]
91+
needs: [ scan-dependencies, scan-codeql, scan-intermediate-image ]
7192
runs-on: ubuntu-latest
7293
strategy:
7394
matrix:
@@ -175,7 +196,7 @@ jobs:
175196
176197
# grype requires that the container image be pushed already because
177198
# the scanner runs in a container with a different local registry
178-
- name: Scan image with grype
199+
- name: Scan final image with grype
179200
id: scan
180201
uses: anchore/scan-action@f6601287cdb1efc985d6b765bbf99cb4c0ac29d8 # v7.0.0
181202
continue-on-error: true

Containerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
# Containerfile for multigres-operator
2+
3+
# Github workflow step anchore/scan-action scan onlys the final image
4+
# sync this intermediate FROM reference with:
5+
# build-and-release.yaml => scan-intermediate-image
16
FROM --platform=$BUILDPLATFORM alpine:3.22.2 AS build
7+
28
ARG TARGETOS
39
ARG TARGETARCH
410

511
COPY dist dist
612
RUN cp dist/multigres-operator-${TARGETARCH}/multigres-operator-${TARGETARCH} multigres-operator
713
RUN chmod +x multigres-operator
814

9-
FROM alpine:3.22.2
15+
FROM gcr.io/distroless/static-debian12
1016

1117
COPY --from=build multigres-operator multigres-operator
1218

0 commit comments

Comments
 (0)