A Production Image for a Node.js App
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).
Rewrite /home/student/projects/feed-builder/Dockerfile so that:
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),node user (it exists in the image),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.
Part of Docker Fundamentals. Next step: A Slim Python Image With a Virtualenv
Teaching or writing about this? Embed this lab on your page
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.