Foundation project
Project: a production-minded application image
Lesson 10 of 20 · 22 min · Module 3: Persistence and a first project
Combine cache-aware assembly, nonroot execution, and an explicit runtime contract.
Start this lesson →Free. No installation: you write and run the code in your browser, and it is checked automatically.
By the end, you’ll be able to…
- Plan the build inputs
- Reduce unnecessary runtime privileges
The idea
Image instructions are an ordered build contract. A later instruction can change a default established earlier; the final stage determines the output image.
01Plan the build inputs
List what dependency installation needs, then what application startup needs. This keeps the installation cache independent of routine source edits.
02Reduce unnecessary runtime privileges
The runtime needs application files and production dependencies. It should not need root merely because the build used a privileged default.
03Review the complete contract
Check the final directory, user, configuration, port, and command together. A correct-looking CMD cannot compensate for missing files in a real build.
Your project brief
What the checks look for
- Uses /app and the requested base
- Installs production dependencies after manifests
- Copies source after installation
- Configures a nonroot production process
Take this with you
A small explicit contract makes an image easier to inspect and operate.
Go a little further
Add a health command and explain which file it expects in the image.