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.

6mAdvanced8,194 students
Video thumbnail for Layers, caching, and multi-stage builds

Sign in to watch this lesson

Browsing is free. Create an account to play videos and track your progress.

Overview

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

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.

Layers, caching, and multi-stage builds — Skiply