A worked example, rendered from real sample data. Sign in to run the tool on your own input.
lang=node version=20 port=3000# syntax=docker/dockerfile:1.7
FROM node:20-alpine AS base
WORKDIR /app
FROM base AS deps
COPY package*.json ./
RUN npm ci --omit=dev
FROM base AS build
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM base AS runtime
COPY --from=deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]

Multi-stage Dockerfile for Node / Python / Go — production-ready. Part of the DevTools Surf developer suite. Browse more tools in the Generators collection.