Asked about Containers and deployment
Why does Dockerfile layer order matter?
An answer that works
Each instruction is a cached layer, and a change invalidates every layer after it. Copying dependency files and installing before copying source means a code change does not reinstall dependencies, which is the difference between a fast build and a slow one.
Reading an answer is not being able to give one. The section that teaches this is Containers and deployment, 5 hours of Containers.
Learn this properly