Skip to content

matsubo/docker_rails_dev_env_example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rails development using docker

Local setup

  • Requirements

  • Download host OS image for docker host OS.

% vagrant box add precise64 http://files.vagrantup.com/precise64.box
  • Build Docker images and run containers.
    • This would take 30 minutes.
    • Password of your host OS is required to mount current directory by NFS.
% vagrant up

Usage

  • d command is utility for rails development.
Usage : ./d command
Commands:
rc - Rails Console
rdbm - Migrate Database
restore-db - Restoring drop db, migrate and put seed
restart - Restart rails app after bundling gems
rebuild - Rebuild the docker container with latest Gemfile and restart
cmd "bundle exec something" - Run the command in quotes in /app
  • To execute rspec
% ./d cmd bundle exec rspec
  • To execute bundle install
% ./d restart
  • To stop host machine, shutdown the Docker host OS on Virtualbox.
% vagrant halt
  • Just want to get a rails server instance.
$ docker run -it -v /app:/app --link redis:redis --link mysql:db rails:latest /bin/bash
  • To acquire console of rails server
    • To exit the console, Ctrl + Z or Ctrl + C
$ docker attach --sig-proxy=false rails

Rebuild

  • Rebuild from VirtualBox VM
  • This takes 30 minutes.
% vagrant destroy && vagrant up
  • Rebuild docker images by referring Dockerfile.
    • This uses docker image cache.
    • bundle install will be ran.
    • This takes 5 minutes.
% vagrant provision

Issues

  • MySQL's permission for docker allows connection from anywhere.
    • I'd like to restrict MySQL incoming connection from rails server and host computer.

Expressions

  • % indicates prompt of host computer.
  • $ indicates prompt of VirtualMachine(=docker host) on vagrant.
  • # indicates prompt of Docker container.

About

Example Rails 4.2 application with a Vagrant + Docker based development environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 75.7%
  • Shell 16.0%
  • CSS 5.7%
  • JavaScript 2.0%
  • CoffeeScript 0.6%