Download and install Vagrant & VirtualBox on your laptop.
The main idea here is that you edit your code locally on your host laptop but you execute specs, run database migrations and run servers inside of Vagrant against the Docker container. Vagrant allows us to use Ubuntu as the OS to run the Docker server (as Ubuntu is the main development environment for Docker), to rapidly install and configure a Docker environment, and to share our code via NFS into the Vagrant/Docker environment. Now all the heavy lifting is done on the exact same Docker image that you'll containerize in production.
Travis-CI both builds the docker image and container and executes specs against it (see .travis.yml). After a successful build, Travis can push the image to a repository, making it the canonical build image and can be updated if either the codebase or the Dockerfile is updated.
The other benefit is that everyone can have the exact same development environment via Vagrant while still using their own Text Editors / IDEs and Browsers to develop and test.
from the root of this directory run vagrant up
vagrant provision
vagrant ssh
cd /app
If you run an ls
command in ~/app, you'll see that code has been shared via directives in Vagrantfile NFS.
docker build -t demo . #where demo is the name of the image you are building.
docker run -dP --name demo_container -p 3000:3000 demo
docker ps
docker exec app_web_1 bin/rake db:migrate
docker exec app_web_1 bin/bundle exec rspec
app_web_1 bin/rake db:migrate RAILS_ENV=development
# From your Host computer, you should be able to access the Rails app @ http://localhost:1234/