> because docker build does not allow you to temporarily mount the cached dependencies.
Why do you believe this point is relevant? If you can mount a drive then you can access its contents on the host, and if you can access files on the host then those contents are also accessible in a Docker build.