Skip to content
Docker

Writing a Dockerfile

Build an image from a Dockerfile with multi-instruction layers.

#dockerfile#build#image

Code

docker
# Dockerfile
FROM node:20-alpine AS base
WORKDIR /app

COPY package*.json ./
RUN npm ci --omit=dev

COPY . .
RUN npm run build

EXPOSE 3000
CMD ["node", "dist/server.js"]

# Build and tag
# docker build -t myapp:1.0 .
# docker history myapp:1.0   # inspect layers