Size audit
Small images pull faster, deploy faster, and rebuild caches faster. The only way to stay small is to measure. docker images gives you the top-line number, and dive shows you which layer is the culprit.
terminal
bash
# Build and size the image
docker build -t fastapi-ai-deploy:latest .
docker images fastapi-ai-deploy
# Inspect layer by layer with dive
dive fastapi-ai-deploy:latest
# Quick sanity: how many megabytes in the venv?
docker run --rm fastapi-ai-deploy:latest du -sh /app/.venv /appdive walks every layer and shows you duplicated files, wasted space, and what each COPY contributed. The du command inside the container is the fastest way to see whether the venv or the code is the size driver.
Ordering exercise: Size reduction order of attack
Loading practice…
Checkpoint: Docker checkpoint
Loading practice…