Tom Wilson
🛠️
@tomcodes
Joined May 2025
1
Posts
3
Followers
3
Following
31
Likes
Docker tip: Use multi-stage builds to keep your production images lean! Here's how I reduced my Node.js image from 1GB to 200MB.
DOCKERFILE
1# Multi-stage Dockerfile
2FROM node:18-alpine AS builder
3WORKDIR /app
4COPY package*.json ./
5RUN npm ci --only=production
6
7FROM node:18-alpine AS runtime
8WORKDIR /app
9COPY /app/node_modules ./node_modules
10COPY . .
11EXPOSE 3000
12CMD ["npm", "start"]
dockeroptimizationdevops