title: Rails 5+, WebPacker and Docker development workflow
body: <p>One of the advantages of using Docker is single environment for entire team. Some time ago I was using Vagrant to unify development environment in a team, and it worked pretty well. Our workflow was like:</p>
  
  <ul>
  <li><p>Run <code>vagrant up</code>, command takes some time to download the base image, run provisioning scripts. It also maps directory from local filesystem to container filesystem.</p></li>
  <li><p>Change file on the host system, all changes will be mapped to guest filesystem (container), so no container restart needed.</p></li>
  </ul>
  
  <p>Some folks use Docker for the similar development workflow, but I usually use <code>docker-compose</code> just to run satellite services. And I was <em>always</em> running Rails monolith inside of host operating system, like natively. </p>
  
  <p>So my development workflow is pretty standard:</p>
  
  <ul>
  <li><p>All the satellite services are up and located inside of Docker containers, I just have a bunch of exposed ports. I don't need to brew-install lots of software to support them, it's good.</p></li>
  <li><p>Rails monolith runs in host OS, so every time I make, for example, <em>JavaScript</em> file change, WebPacker comes into play, rebuilds, and applies changes <strong>without page refresh</strong>. It's important to emphasize, because page refresh takes time, I don't want to refresh the page every time I do JavaScript or CSS file change.</p></li>
  </ul>
  
  <p>With Vagrant the above scheme works well as well. But with Docker things are different.</p>
  
  <p>The development workflow some folks use with Docker is as follows:</p>
  
  <ul>
  <li><p>Run a bunch of services with docker-compose command, except Rails monolith (same step as with my development workflow above).</p></li>
  <li><p>Every time you make change in your app (for example, JavaScript file) you need to rebuild container, because you're making changes on your local filesystem, not inside of a docker container. So you 1) stop 2) build 3) run Docker container again.</p></li>
  </ul>
  
  <p>In other words, with Docker-only approach we have the following cons:</p>
  
  <ul>
  <li>No webpacker js/css refresh</li>
  <li>Container rebuild, which takes time</li>
  <li>Application restart, which takes a lot sometimes, even zero-code "Rails" app starts in ~3 seconds</li>
  </ul>
  
  <p>So my question is: what's the best way to go with Docker-only approach? How you can take advantage of Docker while using WebPacker with Rails and avoid page refresh and application restart?</p>