Lesson 9 of 12 - Containers
Write a Dockerfile that builds fast
By Branko Petric - Updated - About 7 min - Full access
The short answer
Each Dockerfile instruction makes a layer, and Docker reuses cached layers until one changes, then rebuilds everything after it. Put things that rarely change first: copy package files and install dependencies before copying source code. Add a .dockerignore so node_modules, .git and secrets never enter the build.
Want the bigger picture? This lesson maps to this step of the DevOps roadmap.