Lesson 25 / 26
Writing Efficient Dockerfiles
Order instructions and choose base images to keep builds fast and images small.
Order matters for caching
Put instructions that change rarely (installing dependencies) before instructions that change often (copying source code) so cache hits happen more often.
Prefer slim/alpine bases
node:20-alpine can be a tenth the size of node:20. Smaller images pull faster, deploy faster, and have less surface for vulnerabilities.