DEV Community

Cover image for Guide: Rails Development with Docker

Guide: Rails Development with Docker

Nate Vick on December 17, 2019

Originally posted on Hint's blog. As a software consultancy, we switch between many projects throughout the year. A critical factor in delivering ...
Collapse
 
kyleboe profile image
Kyle Boe

If you're a fan of TL;DR's, as Nate linked to, check out Railsdock.

Nate and I have been hard at work demystifying all things Docker so feel free to post comments/questions/PR's and we'll do what we can to shed light on the subject.

GitHub logo hintmedia / railsdock

A tool for generating Ruby on Rails development environment Docker configuration

Railsdock Logo

A command line tool for Dockerizing your Rails development environment.

Prerequisite

The configuration generated by this gem depends on Docker Desktop. Make sure it is installed before continuing.

Installation

Install the gem:

$ gem install railsdock

Or add it to your Gemfile:

gem 'railsdock', require: false, group: :development

Then run:

$ bundle

Usage

Navigate to your project directory:

$ cd /path/to/my/app

Then run:

$ railsdock install

The gem will then walk you through configuring Docker by asking questions about your environment.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle




Collapse
 
talk2megooseman profile image
Erik Guzman

Thanks for the post. It is surprisingly hard to find real good posts on setting up Rails with Docker and this is a great post on the topic. Going to add couple of these little gems to my current Docker setup for my Docker setup.
Do you use the same Dockerfile for production?

Collapse
 
natevick profile image
Nate Vick

We build a base image that we build dev and production from. I plan to do follow up posts. I’ll keep in mind doing one about production as well.

Collapse
 
joshillian profile image
Josh Illian • Edited

This is great! I've been tinkering with a docker setup for development for a while now. Even have a few that I have implemented. None of them are elegant as this. In particular, I've been struggling with some of the issues you tackled in your entrypoint.sh. This is a keeper.

Two notes:
1) the location of the three files (Dockerfile, docker-compose.yml, and entrypoint.sh) are inconsistent as specified in the blog post and referenced in the docker-compose.yml file.

2) a reference to the completed files (Dockerfile, docker-compose.yml, and entrypoint.sh) would be helpful so I'm including a gist to that effect: gist.github.com/joshillian/d601a2e...

Collapse
 
natevick profile image
Nate Vick

Thanks, Josh!

I had those notes while on vacation and haven’t fixed the post. Thanks for the reminder. 😁