Docker development environment for Ruby on Rails
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Dockerfile
LICENSE
README.md
docker-compose.yml
run.sh

README.md

Config files for Ruby on Rails development using Docker

  1. docker-compose up
  2. Profit!

What you get

  • One-line dev environment setup and launch: docker-compose up.
  • One easy-to-install dependency to get coding on a new computer: Docker. (Versus two complex ones when using Vagrant.)
  • Development-oriented config: Source code is mounted so that changes in the container appear on the host, and vice-versa.
  • Fast re-builds because the DOCKERFILE is written to help Docker cache the images.
  • Syncing with Postgres startup delay.
  • All the crappy little dependencies installed.
  • No weird hacks.
  • Tested with current Ruby and Rails as of 2018-02-02: Ruby 2.5.0, Rails 5.1.4

Tested on MacOS and Fedora Linux, because that's what I happen to use. This is my personal configuration that I use for client work and my own projects. It's the result of several late-night hours getting everything working!

How to Dockerize your Rails app

  1. Install Docker somehow. I use Docker for Mac.
  2. Copy the three config files to an existing Rails project. Make run.sh executable, e.g., chmod +x run.sh.
  3. Edit your development database settings to connect to Postgres at host db, username postgres, password empty string.
  4. Spin it up with docker-compose up.

Tests can be run in the container like so:

docker-compose exec web rspec

I create an alias run so that I just do:

run rspec

Or use Spring inside Docker the cheap and easy way:

docker-compose exec web bash
bin/rspec

...then leave that session open and re-run the tests with a fast Spring boot up:

bin/rspec