How to cache the RUN npm install instruction when docker build a Dockerfile
<p>I am currently developing a Node backend for my application.
When dockerizing it (<code>docker build .</code>) the longest phase is the <code>RUN npm install</code>. The <code>RUN npm install</code> instruction runs on every small server code change, which impedes productivity through increased build time.</p>
<p>I found that running npm install where the application code lives and adding the node_modules to the container with the ADD instruction solves this issue, but it is far from best practice. It kind of breaks the whole idea of dockerizing it and it cause the container to weight much more.</p>
<p>Any other solutions?</p>