Copying a Dockerfile pulled in the host node_modules
Docker resolves .dockerignore by the Dockerfile's own name and path, so building a copied Dockerfile with -f ignored the rules and tried to COPY host node_modules.
Two copies drifted
One idea kept by hand in two places — schema and migration, dev and prod, app and app.
Wanted to test-build the prod stage without touching the real file, so I copied it to a scratch directory and built with -f. It failed at COPY . . with cannot copy to non-directory: .../node_modules/@aws-sdk/client-s3, which is a strange error for copying source.
Docker matches .dockerignore by the Dockerfile's name and path: <name>.dockerignore next to it, or a fallback at the context root. The real Backend.Dockerfile.dockerignore (which excludes node_modules) sits next to the real file. My copy had no matching ignore file at its new path and Backend/ has no fallback, so COPY . . pulled the host's real node_modules — pnpm's store, full of symlinks pointing outside the build context — on top of the one the build had just installed.
Stopped copying it and added temporary ARG/ENV lines to the real file instead. A Dockerfile's ignore rules are a property of its path, not its contents, and moving it detaches them silently.