Skip to content

fix(backend): drop lockfile from prod image to clear false Trivy critical#1052

Merged
ogazboiz merged 1 commit into
mainfrom
fix/staging-image-drop-lockfile
Jun 1, 2026
Merged

fix(backend): drop lockfile from prod image to clear false Trivy critical#1052
ogazboiz merged 1 commit into
mainfrom
fix/staging-image-drop-lockfile

Conversation

@ogazboiz
Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz commented Jun 1, 2026

Why

With the Trivy image-ref now fixed (#1050), the Deploy Staging CRITICAL gate runs and fails on a handlebars advisory. But handlebars is a devDependency — the production stage installs prod-only deps (npm ci --omit=dev), so it is never actually in the image.

The failure comes from package-lock.json: it is copied in for npm ci and then left in the image. Trivy reads the lockfile's full dependency tree (including devDependencies) and reports their advisories against the image, even though those packages aren't installed.

Fix

Remove the lockfile after install:

RUN npm ci --omit=dev && rm -f package-lock.json

It's a build-time artifact with no runtime purpose. Dropping it makes the scan reflect what's actually installed (production deps only). The remaining axios advisories are HIGH, which the warn-only Trivy step reports without failing the build.

Verification

Deploy Staging only runs on push to main, so it can't run on this PR — it'll execute on the post-merge run. Change is limited to the backend production Docker stage; it does not affect the PR-gating RemitLend CI job or the app at runtime.

…alse Trivy critical

The Deploy Staging Trivy CRITICAL gate fails on a handlebars advisory. handlebars
is a devDependency and the production stage installs prod-only deps
(npm ci --omit=dev), so it is never actually present in the image. The failure
comes from package-lock.json: it is copied in for npm ci and then left behind,
and Trivy reads the lockfile's full dependency tree — including devDependencies —
and reports their advisories against the image.

Remove the lockfile after install. It is a build-time artifact with no runtime
purpose, and dropping it makes the scan reflect what is actually installed
(production dependencies only). The remaining axios advisories are HIGH, which
the warn-only step reports without failing the build.
@ogazboiz ogazboiz merged commit 6900131 into main Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant