Local Rails Development with Docker and Docker Compose
ashleyconnor.co.uk
ashleyconnor.co.uk
These are arguably downsides of both ruby/rails and docker that combine to make things a little harder to work with than you'd hope.
Still, its a useful workflow if you want to deploy to docker in production. It's nice running the app in the same OS with the same exact dependencies in dev/ci as in prod (plus the same configuration between different people on the team).
The docker for mac setup is seriously bottlenecked by slow volume read/write performance. There is an ongoing discussion here on the issue: https://github.com/docker/for-mac/issues/77. Even after adding the new :cached option to my volume declaration in docker-compose yml file, performance was a huge issue.
My app leverages babel, as I write some react components in ES6 and transpile them to ship to the client. Right now transpilation after changing any javascript code results in a minute + of transpilation time as docker for mac has yet to solve the performance problem. This resulted in a totally unacceptable environment to write code and test in. Also, rails boot time on docker for mac was crazy slow. Running unit tests became a huge pain in the ass.
Not a deal breaker but I prefer to do development on Linux as well for that reason.
Here is a clever way to cache your gems in a separate container https://medium.com/@fbzga/how-to-cache-bundle-install-with-d...
I'm working on an example Docker compose setup that makes use of multi-stage builds to copy the gems into the final container, leaving behind all of the build tools. https://docs.docker.com/engine/userguide/eng-image/multistag...
https://www.stavros.io/posts/how-deploy-django-docker/
Once you've done this, then it becomes trivial to deploy to Dokku, if you have your own VPS or dedicated server. I tried Dokku for the first time a week or so ago and I'm a fan:
(I still appreciate this article, lots of goood info in it :) )
Favourite analogy of the month :D
Docker command line: -v $(pwd):/app
Docker Compose:
app:
volumes:
./:/appFor Docker, dlite uses NFS and doesn't require VirtualBox.
(See README on legacy branch https://github.com/nlf/dlite/tree/legacy )