How do you decide between one big `RUN` and several small ones?
BeginnerProductionBuild Performance & CI
Answer
Group commands that must be atomic for size reasons (install + cleanup). Split steps with different change frequencies (system deps vs app deps). The layer count itself rarely matters; wasted bytes and cache invalidation do. With heredocs the multi-line form stays readable.
More on Build Performance & CI
How do you make Docker builds fast in CI where runners are ephemeral?BeginnerWhat are the cache backends in buildx?BeginnerWhy does `inline` cache often disappoint?AdvancedHow do you structure a Python Dockerfile for the best caching and size?IntermediateHow do you structure a Node.js production image?IntermediateHow do you build a small Java image?Beginner