Keep Secrets and Junk out of the Build Context

easy 10 XP ~5 minHands-on lab

Labs have no container engine, so nothing is built or started: your files are checked by reading them, the way a reviewer or a CI linter would. docker-compose config (to validate Compose files) and hadolint (a Dockerfile linter) are installed.

Building /home/student/projects/chat-relay sends 1.2 GB to the builder, and the image was found to contain the .env file with production secrets.

Task

Create /home/student/projects/chat-relay/.dockerignore so that the build context excludes:

  • the .git folder and node_modules (wherever it is)
  • every .env file and every *.pem key, in any folder, except .env.example
  • every *.log file in any folder, and the coverage/ folder

and still includes everything else: the source, package.json, package-lock.json, Dockerfile and .env.example.

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.

TerminalNot started

Your machine is ready to start

Create a free account to open a machine and get graded.