Development environment (Docker)

Disclaimer: this guide might be outdated because Docker is not our development platform, for updated instructions check Development environment

Setting up the development environment with Docker

Overview

  1. For Linux users, we need you to install Docker engine and Docker compose. Make sure you have Docker compose version 1.6 or higher by executing
$ docker-compose version
  1. For PC and Mac users we need you to install Docker toolbox for Mac and Windows and use Docker Machine to create a virtual machine to run your Docker containers. Once your machine is created and you have connected your shell to this new machine, you're ready to run Docker commands on this host. If you're using Linux you can skip to the next step.

Configuration

$ cp config/database.yml.example config/database.yml
$ cp .env.example .env

Fill all the values of the new .env file (see environment variables description document if you need a detailed description of each variable).

If you are using rbenv you should:

  1. Check you have rbenv-vars plugin installed
  2. Symlink .env to .rbenv-vars file. Yo can do this by running:
$ ln -s .env .rbenv-vars
  1. Verify variables are properly configured by running rbenv vars. You should see something like:
export INTEGRATION_DEBUG='false'
export INTEGRATION_INSPECTOR='false'
export TEST_LOG_LEVEL='debug'
export RACK_ENV='development'
export RAILS_ENV='development'
export HOST='gobierto.test'
...

Set up

$ docker-compose up -d
$ docker-compose run web bundle install
$ docker-compose restart

If you get a "Couldn't connect to Docker daemon - you might need to run 'docker-machine start default'." error when running docker-compose up -d, but the docker machine is indeed running, you might want to take a look at this issue.

Seeding the databases

$ docker-compose run web script/setup

Accessing the Docker host

If you are using Docker Machine, run this command to get your current Docker host's IP:

$ docker-machine ip <your_docker_machine_name>

Application server

After having started all Docker containers via the docker-compose
command, the application will be reachable at:
http://<your_docker_host>:3000/

Tests

To run the entire test suite:

$ docker-compose run test

Development top-level domain and port proxying

The application server should be queried through the top-level domain .gobierto.test. For this purpose you could use [puma-dev]https://github.com/puma/puma-dev)'s Port Proxying feature:

$ echo http://<your_docker_host>:3000 > ~/.puma-dev/gobierto

So, since port 3000 is forwarded through the corresponding Docker containers, the app instance should be just reachable at http://madrid.gobierto.test.

Mailcatcher

To use MailCatcher, make sure the mailcatcher container is up and running:

$ docker-compose up -d mailcatcher

Having done this, the server should be available at http://<your_docker_host>:1080.

Using xip.io

Check how to use xip.io in https://github.com/PopulateTools/gobierto/blob/master/docs/development-environment.md