Asked about A Dockerfile that builds fast and runs safely
Your Docker build takes eight minutes on every code change. Why, and how do you fix it?
An answer that works
The code is probably copied before dependencies are installed, so every change invalidates the install layer. Copy the requirements file and install first, then copy the code. Add a .dockerignore so unrelated files do not bust the cache.
Then they push further
It is still slow in CI. Why?
CI machines often start with an empty cache. Use your CI's Docker layer caching, or push and pull a cache image from the registry.
What gets marked up
Marked up for explaining layer caching and ordering, not just 'use a smaller image'.
Reading an answer is not being able to give one. The section that teaches this is A Dockerfile that builds fast and runs safely, 4 hours of Containers.
Learn this properly