The Docker CLI packages the entire build context directory and sends it to the daemon before the first instruction runs. Without a .dockerignore file that includes .git, node_modules, and build output directories, a repository with a long history can ship hundreds of megabytes on every build.
The cost is not only transfer time. Because those files are part of the context, COPY . . includes them, so a change to any file under .git after a commit invalidates the layer cache for the copy and everything downstream. A stale host node_modules copied into the image can also shadow the correctly built one, producing native modules compiled for the wrong platform.
Confirm the size with the transferring context line BuildKit prints at the start of a build. Add a .dockerignore with at least .git, node_modules, and the local build output directory. The file uses the same pattern syntax as .gitignore and lives next to the Dockerfile's context root, not next to the Dockerfile itself.