The layer-ordering point is the one that saves real time. Put the dependency install before the code copy and most rebuilds stop reinstalling everything after a one-line change. The .dockerignore point belongs right next to it — I've seen a stray .env or a huge local folder quietly shipped into an image more than once. And the exec-form CMD note is easy to overlook until a deploy hangs because SIGTERM never reaches the app.
Shubham Chaudhary
Frontend developer · building free tools for learners
When I was learning Docker, my first-ever Docker image was ridiculously huge, and that was just for a simple Vite app created using "npm create vite@latest" and "npm install". Back then, I had no idea that .dockerignore even existed. Once I learned about it, I realised how much unnecessary stuff I was including in the build context.