From d51cd5e9216df98977d12379b544233e17a78ab0 Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Thu, 8 Jan 2026 13:10:37 +0100 Subject: [PATCH 1/3] feat: improve docker build --- .github/workflows/docker-build.yml | 53 ++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 493805d..686dcc2 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -74,36 +74,23 @@ jobs: username: ${{ secrets.username }} password: ${{ secrets.password }} - - name: Build Docker Image + - name: Build Docker image uses: docker/build-push-action@v6 with: build-args: ${{ inputs.build-args }} context: ${{ inputs.context }} file: ${{ inputs.dockerfile }} platforms: ${{ inputs.platforms }} - push: ${{ inputs.push }} + load: true # Make the image available on runner + push: false # Don't push yet, wait for security checks tags: ${{ inputs.image-name }}:${{ inputs.image-tag }} - - name: Build Docker Image as Tarball - if: ${{ inputs.security-scan }} - run: | - BUILD_ARGS="" - if [ -n "${{ inputs.build-args }}" ]; then - while IFS= read -r line; do - if [ -n "$line" ]; then - BUILD_ARGS="$BUILD_ARGS --build-arg $line" - fi - done <<< "${{ inputs.build-args }}" - fi - docker build $BUILD_ARGS -t ${{ inputs.image-name }}:${{ inputs.image-tag }} -f ${{ inputs.dockerfile }} ${{ inputs.context }} - docker save -o vuln-image.tar ${{ inputs.image-name }}:${{ inputs.image-tag }} - - name: Run Trivy vulnerability scanner id: trivy if: ${{ inputs.security-scan }} - uses: aquasecurity/trivy-action@0.29.0 + uses: aquasecurity/trivy-action@0.33.1 with: - input: vuln-image.tar + image-ref: ${{ inputs.image-name }}:${{ inputs.image-tag }} format: ${{ (inputs.security-report == 'sarif' && 'sarif') || 'table' }} ignore-unfixed: true vuln-type: "os,library" @@ -196,3 +183,33 @@ jobs: ${{ steps.read_hadolint.outputs.report }} ``` + + - name: Fail build on CRITICAL or HIGH vulnerabilities + if: ${{ inputs.security-scan }} + uses: aquasecurity/trivy-action@0.33.1 + with: + image-ref: ${{ inputs.image-name }}:${{ inputs.image-tag }} + format: ${{ (inputs.security-report == 'sarif' && 'sarif') || 'table' }} + ignore-unfixed: true + vuln-type: "os,library" + severity: "CRITICAL,HIGH" + hide-progress: true + skip-setup-trivy: true + exit-code: 1 + + - name: Build and push Docker image + if: ${{ inputs.push }} + uses: docker/build-push-action@v6 + with: + build-args: ${{ inputs.build-args }} + context: ${{ inputs.context }} + file: ${{ inputs.dockerfile }} + platforms: ${{ inputs.platforms }} + push: true + tags: ${{ inputs.image-name }}:${{ inputs.image-tag }} + + - name: Cleanup files + if: always() + run: | + rm -f trivy.txt trivy-results.sarif + docker image rm -f ${{ inputs.image-name }}:${{ inputs.image-tag }} From 0d1811667e1656f6f6e7742e4800559693faadbe Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 12 Jan 2026 13:02:43 +0100 Subject: [PATCH 2/3] fix: docker build needs to be single-platform to load --- .github/workflows/docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 686dcc2..66dced4 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -80,7 +80,7 @@ jobs: build-args: ${{ inputs.build-args }} context: ${{ inputs.context }} file: ${{ inputs.dockerfile }} - platforms: ${{ inputs.platforms }} + platforms: "linux/amd64" load: true # Make the image available on runner push: false # Don't push yet, wait for security checks tags: ${{ inputs.image-name }}:${{ inputs.image-tag }} From 7e1a11142b3bbf612ff28cc5197822c3bf90f732 Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 12 Jan 2026 13:03:13 +0100 Subject: [PATCH 3/3] fix: more comprehensive first Trivy analysis --- .github/workflows/docker-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 66dced4..b829a3c 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -92,9 +92,7 @@ jobs: with: image-ref: ${{ inputs.image-name }}:${{ inputs.image-tag }} format: ${{ (inputs.security-report == 'sarif' && 'sarif') || 'table' }} - ignore-unfixed: true vuln-type: "os,library" - severity: "CRITICAL,HIGH" hide-progress: true output: ${{ (inputs.security-report == 'sarif' && 'trivy-results.sarif') || 'trivy.txt' }}