Node.js › Cloud & DevOps
What is the purpose of a .dockerignore file when preparing a Node.js project for cloud deployment?
BeginnerAnswer
A .dockerignore file excludes files -- most importantly node_modules, .env files, and local build artifacts -- from being copied into a Docker build context, keeping images smaller and preventing accidentally baking local secrets or a platform-specific node_modules into a production image.
node_modules
npm-debug.log
.env
.git
coverageReal-world example A team's Docker images failed on a different CPU architecture until adding .dockerignore excluding node_modules, forcing 'npm ci' inside the build to install correctly-architected dependencies.