mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
+7
-2
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user