/docker-compose-rails-dev-example

A Docker compose project example I use to develop rails apps with Docker

Primary LanguageRubyMIT LicenseMIT

Example of a Rails App with Docker Compose for development

This is an example of how I use Docker and Docker Compose to develop my rails apps.

It is an ideal project setup for new and experienced developers alike, and allows to a nearly trouble-free environment setup in their development machines.

In this example we'll fire up a full app environment consisting of the following:

You'll need to follow some instructions to get this example running:

1: Requirements

You must have both Docker (or a Docker Machine host) and Docker Compose running on your machine.

You can find instructions for the recommended setup on Linux, Mac OSX and Windows 8+.

2: Cloning the project

You should clone the project into a conveniently-named directory, as this repo's name is big enough to make typing docker/compose commands tiresome, should the need arise:

git clone https://github.com/vovimayhem/docker-compose-rails-dev-example.git example

3: Initialize the app environment in an initial run:

The setup-development-with-docker.sh script will do the following:

  1. Generate an .env file, into which we'll store sensitive info (passwords, SECRET_KEY_BASE, etc). This file shouldn't be in version control
  2. Generate the app's config/secrets.yml file, which will read the SECRET_KEY_BASE environment variable for all rails app environments.
  3. Run the bundler command to install the app dependencies in the app's vendor/bundle folder.
  4. Run the 'rake db:setup' command to initialize the database.
cd example && ./setup-development-with-docker.sh

Edit if you need the generated .env file.

4: Bring online the project's containers

docker-compose up -d

That's it! Check the running app web interface: http://localhost:3000

5: Next steps

I usually do some tricks to aid in my day to day activities:

6: Example app ruby version

It uses MRI ruby 2.2.2. I'll make some branches using different engines (i.e. Rubinius, JRuby)

7: More Information

8: Contributing

I'd love to receive feedback & suggestions from everyone. If you see something off, or think there's a better way to do something this thing does, please do:

  • Fork the original repository.
  • Make your changes in a topic branch.
  • Send a pull request.

License

This is free software, and may be redistributed under the terms specified in the LICENSE file.