Building Rails 5 (Puma) + Nginx + MySQL with docker-compose on Vagrant (Ubuntu)
This is a docker-compose setup I use as a template for my own Rails development environment.
Here are the setup steps.
Starting Vagrant
1 | macOS%$ git clone https://github.com/kenzo0107/vagrant-docker |
Creating the Rails Project
1 | // on vagrant |
Setting the Puma Configuration File
1 | vagrant%$ cp puma.rb ./rails/config/ |
- ./rails/config/puma.rb
1 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i |
Setting the Database Configuration File
1 | vagrant%$ cp database.yml ./rails/config/ |
- ./rails/config/database.yml
1 | default: |
Creating the Database
1 | vagrant%$ docker-compose run --rm web rails db:create |
With that, we have prepared the bare minimum Rails project!
Starting All Containers: Rails, Nginx, MySQL
1 | vagrant%$ docker-compose up -d |
Access http://192.168.35.101 from your browser, and you can confirm that the Rails top page is displayed.
Conclusion
Because everything is containerized with Docker, it is convenient to be able to easily check the look and feel or verify functionality just by swapping out a container, even when you want to upgrade the versions of Nginx, MySQL, and so on.
By adding Elasticsearch + Kibana to visualize logs, or Mailcatcher to confirm email sending, you can prepare an environment that is more than sufficient for development.
I hope this can be of help to your development.
Building Rails 5 (Puma) + Nginx + MySQL with docker-compose on Vagrant (Ubuntu)
https://kenzo0107.github.io/en/2017/09/13/docker-compose-rails5-nginx-mysql-on-vagrant/
