Docker image layers and caching
Change one line of source and the rebuild runs npm install from scratch. An image is a stack of layers, and Docker caches build results layer by layer. When one layer is invalidated, everything below it rebuilds too. So the order of instructions in a Dockerfile determines build speed. The sections below build images, catch the cache breaking in the docker build log, and measure how an ordering change moves the build time. Every output comes from a run on Docker 29.3.1. ...