Category: Database, Docker, Redis

My goal is to walk you through setting up an ergonomic and reproducible development environment for building Ruby on Rails applications. The Docker configuration was created with the following goals in mind: To support the above, the architecture will look like this: The Rails application I will be “dockerizing” features a PostgreSQL database and Redis (for Action Cable) and is named restarone.

The Rails test environment is simply mapped to the already built Rails dev environment image, but it will run in a separate container and network.

First we need to build the containers, and then we run them: To use breakpoints with byebug/pry, you can simply prefix the directory name of the project followed by app(my directory is called restaroneso the app is called restarone_app and the test environment is called restarone_test): We can spin up a one-off container for the test suite and then tear it down after the suite completes by running: Simply pass in whatever test command your application uses.

In the following example, I’m using the Docker exec command to run a psql command directly on a running restarone_db container: Rails is amazing, and when packaged with Docker you get an elegantly portable and deterministic Rails development environment you can build with from anywhere, anytime.

Related Articles