wtf( )unctionsystem design, drawn
← all problemsContainersMedium

A one-line change, a four-minute build

The image copies the whole working tree in, then installs dependencies, then compiles. Every commit — including a typo in a comment — reinstalls every dependency from the network.

The file is correct. It is written in the order a person would describe the work, which is the reverse of the order a cache wants.

Put the step that changes rarely in front of the step that changes on every commit.
Components — tap one, then tap a slot on the diagram
?Layer order decides whether a source change reuses the cache or rebuilds the world.

Boundaries, outermost first: Image build: Install dependencies (90s, from the network), Compile, an empty slot for the the first copy, an empty slot for the the second copy Outside every boundary: Image, Working tree (changes every commit) Connections: the first copy calls Install dependencies (step 1) Install dependencies calls the second copy (step 2) the second copy calls Compile (step 3) Compile calls Image (step 4) Working tree controls the first copy — two files Working tree controls the second copy — everything else

Image
Working treechanges every commit
Install dependencies90s, from the network
Compile