It is not clear what you mean by
Is it mounted to the container or to the host before you run docker build?
If it is mounted to the container
There is no way to do that. You can only change permissions to make sure not everyone can access everything, but you can’t bind mount a folder and not mount something in that folder.
You can’t do anything to solve it in a Dockerfile, since that only runs during the build process so before you mount anything. Even if it could run when you want it to run, it would remove the files on the host which you probably not want to do.
If it is mounted to the host before running docker build
It shouldn’t matter whether the files were mounted from somewhere else or existed in the project root directly.
Related topics
Since you started a similar topic before, I guess it is related to that issue