Lesson 1.27mAdvanced8.2k students
Layers, caching, and multi-stage builds
Instruction order decides your build time. Copy dependency manifests before source, and use a multi-stage build to leave the toolchain behind.
This lesson sits in Containers and Images, part of DevOps with Docker and Kubernetes. It assumes what came before it and leads directly into the next lesson in the module.
In this lesson you will
- Order instructions so the cache survives code changes
- Separate build and runtime with multi-stage builds
- Cut image size and shrink the attack surface
Pro tip
Copy your lockfile and install dependencies before copying source. Otherwise every edit invalidates the install layer.
Resources
Your notes for this lesson will appear here.