1818
1919# syntax=docker/dockerfile:1
2020
21- # Use Node.js 22.21 LTS Alpine with security patches
22- ARG NODE_VERSION=22.21-alpine3.23
21+ # Use Node.js 22.22 LTS Alpine with security patches
22+ ARG NODE_VERSION=22.22-alpine3.23
23+
24+ # Bun version used in build stages (must match packageManager in package.json)
25+ ARG BUN_VERSION=1.3.13
2326
2427# Get Railway service ID for cache mounts
2528ARG RAILWAY_SERVICE_ID
2629
2730# =============================================================================
2831# STAGE 1: Base Image
2932# =============================================================================
30- # Alpine Linux 3.21 base for minimal image size with latest security updates
33+ # Alpine Linux 3.23 base for minimal image size with latest security updates
3134FROM node:${NODE_VERSION} AS base
3235
3336# Install security updates for Alpine packages
@@ -45,9 +48,11 @@ WORKDIR /usr/src/app
4548# image, keeping the production image smaller and reducing attack surface.
4649FROM base AS bun-base
4750
51+ # Re-declare ARG so the global value is accessible in this stage
52+ ARG BUN_VERSION
53+
4854# Install Bun for dependency management
49- # Note: Version must match packageManager field in package.json (currently 1.3.11)
50- RUN npm install --global bun@1.3.11
55+ RUN npm install --global bun@${BUN_VERSION}
5156
5257# =============================================================================
5358# STAGE 2: Production Dependencies
@@ -78,6 +83,10 @@ RUN --mount=type=bind,source=package.json,target=package.json \
7883COPY . .
7984RUN bun run build
8085
86+ # Create a production-only package.json (strip devDependencies so Docker Scout
87+ # does not flag transitive dev-only packages like picomatch@^2.x from nodemon)
88+ RUN node -e "const p=require('./package.json');delete p.devDependencies;process.stdout.write(JSON.stringify(p,null,2));" > /tmp/package-prod.json
89+
8190# =============================================================================
8291# STAGE 4: Final Runtime Image
8392# =============================================================================
@@ -92,8 +101,9 @@ ENV NODE_ENV=production \
92101RUN addgroup -g 1001 -S nodejs && \
93102 adduser -S nodejs -u 1001 -G nodejs
94103
95- # Copy package.json for package manager commands
96- COPY --chown=nodejs:nodejs package.json .
104+ # Copy production-only package.json (no devDependencies) to avoid Docker Scout
105+ # false-positives from dev dep chains that reference picomatch@^2.x
106+ COPY --from=build --chown=nodejs:nodejs /tmp/package-prod.json ./package.json
97107
98108# Copy production dependencies and built application
99109COPY --from=deps --chown=nodejs:nodejs /usr/src/app/node_modules ./node_modules
0 commit comments