Rails-5 application deploy configuration using puma and nginx.
- Optional configuration of production and staging environments in same server.
- Embedded Nginx configuration.
- Embedded Puma init script and puma configuration.
- Log rotation.
Require following gems to be included in Gemfile.
- puma
- capistrano
- capistrano-bundler
- capistrano-rails
- capistrano-rbenv
gem 'puma', '~> 3.9', '>= 3.9.1'
group :development do
gem 'capistrano', '~> 3.9'
gem 'capistrano-bundler', '~> 1.2'
gem 'capistrano-rails', '~> 1.3'
gem 'capistrano-rails-console', '~> 2.2'
gem 'capistrano-rbenv', '~> 2.1', '>= 2.1.1'
end
- Copy following files in your application root maintaining the structure:
├── config
│ ├── deploy
│ │ ├── shared
│ │ │ ├── application.yml.template.erb
│ │ │ ├── database.yml.template.erb
│ │ │ ├── log_rotation.erb
│ │ │ ├── nginx.conf.erb
│ │ │ ├── puma.rb.erb
│ │ │ ├── puma_init.sh.erb
│ │ │ └── secrets.yml.template.erb
│ │ ├── production.rb
│ │ └── staging.rb
│ └── deploy.rb
├── lib
│ └── capistrano
│ ├── tasks
│ │ ├── check_revision.cap
│ │ ├── compile_assets_locally.cap
│ │ ├── logs.cap
│ │ ├── monit.cap
│ │ ├── nginx.cap
│ │ ├── restart.cap
│ │ ├── run_tests.cap
│ │ └── setup_config.cap
│ ├── substitute_strings.rb
│ └── template.rb
└── Capfile
-
Put rails project's git url under :repo_url in 'config/deploy.rb' file.
Example:
#config/deploy.rb set :repo_url, 'git@github.com:user/repo.git'
-
Change application name under :application in 'config/deploy.rb' file.
Example:
#config/deploy.rb set :application, 'demo_application'
-
Set server name in 'config/deploy/production.rb' and 'config/deploy/staging.rb' under :server_name
Example:
# config/deploy/production.rb set :server_name, 'example.prod'
# config/deploy/staging.rb set :server_name, 'example.stage'
-
Set Ip Address in 'config/deploy/production.rb' and 'config/deploy/staging.rb' under server
Example:
server '192.168.33.10', user: ...
-
To upload configurations
$ bundle exec cap production deploy:setup_config
-
To deploy
$ bundle exec cap production deploy
Bug reports and pull requests are welcome on GitHub at puma-deploy repository. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
- Indrajit Roy - Owner - eendroroy
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details