1. Concept library
  2. Backend with Node.js
  3. Module 11: Deployment

Concept

Containers

A container image packages Node, your code and its dependencies so it runs the same on a laptop and in production. A small, non-root image with only production dependencies is the goal.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain what a container image packages and why it should be small
  2. Write a Dockerfile that installs only production dependencies and runs as non-root
  3. Spot the node_modules and .env copied into the image

In practice

A few lines that show Containers doing its job.

dockerfile
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev

FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY src ./src
USER node
EXPOSE 3000
CMD ["node", "src/server.js"]

The common mistake

Watch for

Copying the whole project, including node_modules and .env, into the image. The image bloats, native modules built for the wrong platform break, and secrets ship in every layer.

What to know first

Your roadmap puts these before Containers, unless you already know them.

How it stays learned

Once a session shows you understand Containers, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled
Previous in the module← Environment configuration
Next in the moduleLogging and monitoring →