title: npm install with a docker-compose project
body: <p>I have a dockerized project that has three apps and three databases. The three apps are written in node and use <code>npm</code> as usual.</p>
  
  <p>I have a script that clones the three repos, <code>docker-compose.yaml</code> mounts the three containers and uses a <code>Dockerfile</code> for each of the three projects to basically just do an <code>npm install</code> and run them.</p>
  
  <p>This is all working fine, but the whole point of this exercise is to make the cluster of projects easy to set up and run for the purposes of development. Actually working on the project code is not a problem since it gets cloned by the developer, but <code>npm install</code> is done through docker and thus root. This means that <code>node_modules</code> in the repos is owned by root.</p>
  
  <p>A developer cannot simply do <code>npm install</code> to add a new package to the repo because they won't have permissions on <code>node_modules</code> and the module would possibly be built with a different architecture depending on their host system.</p>
  
  <p>I have thought about creating a script that runs <code>npm install</code> in the container instead, but this has a couple of caveats:</p>
  
  <ol>
  <li><code>root</code> would own <code>package.json</code></li>
  <li>This breaks a typical node developer's flow ... they are used to just doing <code>npm install</code></li>
  </ol>
  
  <p>Like I said above, the whole point of this is to make it as easy to jump in and develop as possible, so I want to get as close to a common development experience as I can.</p>
  
  <p>Are there any suggestions for handling installation of node modules in a docker container for development of a project?</p>