Skip to content

Instantly share code, notes, and snippets.

@jgcmarins
Created June 30, 2025 14:32
Show Gist options
  • Save jgcmarins/e6909359b84b2623ba7893e9c54dce0c to your computer and use it in GitHub Desktop.
Save jgcmarins/e6909359b84b2623ba7893e9c54dce0c to your computer and use it in GitHub Desktop.
Node.js Dockerfile for perfomance
FROM node:22.16-alpine AS builder
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
RUN yarn build
RUN rm -rf node_modules && yarn install --production --frozen-lockfile
FROM alpine AS runtime
WORKDIR /app
RUN apk add --no-cache nodejs-lts
COPY --from-builder /app/package.json ./
COPY --from-builder /app/node_modules ./node_ modules
COPY --from-builder /app/dist ./dist
EXPOSE 3000
CMD ["node", "dist/main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment