From b338e1abb4feaf98344e5cb4497b51b89088f54a Mon Sep 17 00:00:00 2001 From: Philipp Traber Date: Wed, 14 Oct 2026 18:34:49 +0200 Subject: [PATCH] Use a minimal Alpine runtime image without npm The node:24-slim image had 262 known vulnerabilities (Trivy), almost all in Debian system packages, plus 21 in the npm bundled with Node. None were in the app's own dependencies. The runtime now uses node:24-alpine with npm, npx, corepack and yarn removed and Alpine security updates applied: 0 known vulnerabilities. Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57b0072..8653761 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:24-slim AS base +FROM node:24-alpine AS base WORKDIR /app RUN corepack enable COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ @@ -11,7 +11,12 @@ RUN pnpm build FROM base AS prod-deps RUN pnpm install --frozen-lockfile --prod -FROM node:24-slim AS runner +FROM node:24-alpine AS runner +# The app only needs the node binary. npm, npx, corepack and yarn ship with the base image and carry +# most of its known vulnerabilities, so they're removed; pending Alpine security updates are applied. +RUN apk upgrade --no-cache \ + && rm -rf /usr/local/lib/node_modules /usr/local/bin/npm /usr/local/bin/npx /usr/local/bin/corepack \ + /usr/local/bin/yarn /usr/local/bin/yarnpkg /opt/yarn-* WORKDIR /app ENV NODE_ENV=production \ PORT=3000 \