24/53
Sign inSign up free

837. A Production Image for a Node.js App

medium 20 XP ~9 minHands-on lab

Labs have no container engine, so nothing is built: your files are checked by reading them.

The image of feed-builder is 1.2 GB, contains jest, eslint and typescript, runs as root, and takes 10 seconds to stop on every deploy (npm start doesn't pass SIGTERM on to the app).

Task

Rewrite /home/student/projects/feed-builder/Dockerfile so that:

  • it uses node:20-slim, with WORKDIR /app,
  • NODE_ENV=production is set before dependencies are installed,
  • package.json and package-lock.json are copied first, then dependencies installed with npm ci --omit=dev (no npm install),
  • the rest of the source is copied after that, owned by the node user (it exists in the image),
  • the container runs as node, still EXPOSEs 3000, and starts with CMD ["node", "server.js"].

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.