Docker Community Forums

Share and learn in the Docker community.

Using cache in a multi stage build scenario

I would like to build my frontend project in docker. I have a two staged docker file.
The first stage does the npm install / test / build. And the second one copies the output into an nginx image.

Everything is working fine, however i have one problem. The build time is high because the build always have to build up the whole node_modules folder. I would like to have this folder from a volume. I see how can i achieve this with multiple dockerfiles. Is there any alternative in a multi staged dockerfile or this is a use case not supported by multi stage builds?

Thanks!