Skip to content

Commit bacf4f5

Browse files
authored
fix: OS package upgrades run on every image build, so Trivy stops failing on fixes the cache hid (#417)
1 parent 0338278 commit bacf4f5

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ jobs:
469469
tags: integr8scode-frontend:latest
470470
cache-from: type=gha,scope=frontend
471471
cache-to: type=gha,mode=max,scope=frontend
472+
# A cached `apk upgrade` layer would keep OS packages from the day it was cached
473+
no-cache-filters: production
472474

473475
# ── Push all images to GHCR in parallel ────────────────────────
474476
- name: Push all images to GHCR

‎backend/Dockerfile‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ FROM python:3.14-slim AS base
3232
WORKDIR /app
3333

3434
# Runtime libs only (no -dev headers, no gcc); uv installs the app, so pip goes too, since its vendored packages trip the scan
35-
RUN apt-get update && apt-get upgrade -y \
35+
RUN apt-get update \
3636
&& apt-get install -y --no-install-recommends \
3737
curl \
3838
liblzma5 \
@@ -57,6 +57,9 @@ ENV OTEL_SEMCONV_STABILITY_OPT_IN=http
5757

5858
FROM base
5959

60+
# CI caches the base stage's layers, so OS fixes released after that come in here, on every build
61+
RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*
62+
6063
# Copy application files and configuration
6164
COPY ./app /app/app
6265
COPY ./scripts /app/scripts

‎docs/security/supply-chain.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Findings show up in the repository's Security tab under code scanning, as `backe
1010

1111
## Image and code scans
1212

13-
Docker Scan & Promote runs Trivy v0.75.0 on the `backend` and `frontend` images of every commit that passed CI on `main`. It reports `CRITICAL` and `HIGH` findings that have a fix, skips anything listed in `backend/.trivyignore`, and uploads SARIF per image as `trivy-<image>`. A finding fails the job and blocks the promote to `latest`. The images keep the count at zero by upgrading their OS packages at build time, and the backend drops pip, whose vendored packages were the only Python findings. The ignore file lists no CVE today. See [CI/CD](../operations/cicd.md#docker-scan-promote).
13+
Docker Scan & Promote runs Trivy v0.75.0 on the `backend` and `frontend` images of every commit that passed CI on `main`. It reports `CRITICAL` and `HIGH` findings that have a fix, skips anything listed in `backend/.trivyignore`, and uploads SARIF per image as `trivy-<image>`. A finding fails the job and blocks the promote to `latest`. The images keep the count at zero by upgrading their OS packages in a step CI never caches (the backend's last stage, the frontend's `production` stage), so a fix released after a cached build still gets in, and the backend drops pip, whose vendored packages were the only Python findings. The ignore file lists no CVE today. See [CI/CD](../operations/cicd.md#docker-scan-promote).
1414

1515
CI's Security Scanning job runs `uvx --no-build --python 3.14 bandit==1.9.4 -r backend/ -x backend/tests/ -ll` on pushes to `main` and on PRs that change `backend/`. `-ll` reports medium severity and up, and any finding fails the workflow.
1616

‎frontend/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN npm run build
1111

1212
# --8<-- [start:production_stage]
1313
# Production stage
14-
FROM nginx:1.31-alpine
14+
FROM nginx:1.31-alpine AS production
1515

1616
# Upgrade the base image's packages to pick up fixes newer than the image, and add curl for the healthcheck and openssl for the certificate
1717
RUN apk upgrade --no-cache && apk add --no-cache curl openssl

0 commit comments

Comments
 (0)