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.
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