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.

Duration
7m
Level
Advanced
Students
8.2k students

Overview

Instruction order decides your build time. Copy dependency manifests before source, and use a multi-stage build to leave the toolchain behind.

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

Resources

Kubernetes documentation

The official reference for the tools used in this lesson.