Back

Dockerfile basics

A Dockerfile is a list of steps for building an image: pick a base image, copy your code, install dependencies, and say how to start the app. Copy package.json first so Docker can cache the install step.

# Dockerfile
FROM node:20-alpine
WORKDIR /app

COPY package*.json ./
RUN npm ci

COPY . .
RUN npm run build

EXPOSE 3000
CMD ["npm", "start"]

# Build and run
docker build -t my-app .
docker run -p 3000:3000 my-app

Roadmap