Lesson 1.2
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.
7mAdvanced8.2k students
Overview
What this lesson covers
- Order instructions so the cache survives code changes
- Separate build and runtime with multi-stage builds
- Cut image size and shrink the attack surface
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.
Your notes will live here soon.