A Docker container for bootstrapping a Docker Rails development environment
docker run -ti -u $(id -u) -v $(pwd):/work fishpercolator/rails-new $appname
Or, if you plan to use this a lot, make an alias:
alias rails-new='docker run -ti -u $(id -u) -v $(pwd):/work fishpercolator/rails-new'
rails-new $appname
After the environment has been bootstrapped:
cd $appname
docker-compose build
vim Gemfile # add your favourite gems
docker-compose run web bundle
docker-compose run web rake db:create
docker-compose up
And lo, your new application should be ready to go at http://localhost:3000.
- It runs 'rails new' with your app name and any arguments you provide.
- It adds a Dockerfile and docker-compose.yml to the directory for building out the dev environment. The Dockerfile includes a user 'rails' with the same uid as your host user so fails generated by Rails will have the right ownership.
- It configures the development and test databases to use the provided postgres container.
- It adds puma, therubyracer and rails_12factor to the Gemfile and configures puma with a config/puma.rb
On Github: https://github.com/fishpercolator/docker-rails-new