Your Docker build re-installs all Python dependencies on every code change. Fix it.
BeginnerScenarioImage design and Dockerfile decisions
Answer
Situation read → COPY . . comes before pip install, so any file change busts the cache.
What I'd do →
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
Add a .dockerignore so irrelevant changes (.git, __pycache__) do not invalidate COPY . . either.
Why → Layers are cached top-down; order from least to most frequently changing.
Interview tip → State the rule: "dependencies manifest first, source last."
More on Image design and Dockerfile decisions
A teammate's Node.js image is 1.2 GB. How do you approach shrinking it?BeginnerYou need to run `apt-get install` in a Dockerfile. How do you write it so the layer stays small and cache-safe?BeginnerWhen would you pick `COPY` over `ADD`?BeginnerA service must run a startup script and then the app. Should you use `CMD`, `ENTRYPOINT`, or both?BeginnerProduct asks for a container that runs both nginx and a Python app. What do you say?BeginnerYour app ignores `docker stop` and takes exactly 10 seconds to die. Why and what do you change?Intermediate