puma-deploy

Puma Deploy

Contributors GitHub last commit (branch) license GitHub issues GitHub closed issues GitHub pull requests GitHub closed pull requests

Rails-5 application deploy configuration using puma and nginx.

Description

Prerequisites

Requires following gems.

gem 'puma'
group :development do
  gem 'capistrano'
  gem 'capistrano-bundler'
  gem 'capistrano-rails'
  gem 'capistrano-rails-console'
  gem 'capistrano-rbenv'
end

Installing

.
├── Capfile
├── 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
      ├── substitute_strings.rb
      ├── tasks
      │  ├── check_revision.cap
      │  ├── compile_assets_locally.cap
      │  ├── db.cap
      │  ├── logs.cap
      │  ├── monit.cap
      │  ├── nginx.cap
      │  ├── puma.cap
      │  ├── push_deploy_tag.cap
      │  ├── run_tests.cap
      │  └── setup_config.cap
      └── template.rb

Example:

#config/deploy.rb
set :repo_url, 'git@github.com:user/repo.git'

Example:

#config/deploy.rb
set :application, 'demo_application'

Example:

server '192.168.33.10', user: fetch(:deploy_user).to_s, roles: %w(app db), primary: true
server '192.168.33.11', user: fetch(:deploy_user).to_s, roles: %w(app), primary: true
server '192.168.33.12', user: fetch(:deploy_user).to_s, roles: %w(app), primary: true
# config/deploy/production.rb
set :server_names, {
  '192.168.33.10': '192.168.33.10 node0.server',
  '192.168.33.11': '192.168.33.11 node1.server',
  '192.168.33.12': '192.168.33.12 node2.server',
}
set :nginx_certificate_path, "#{shared_path}/certificates/#{fetch(:stage)}.crt"
set :nginx_key_path, "#{shared_path}/certificates/#{fetch(:stage)}.key"

For different certificate and key name in different server

set :nginx_certificate_paths, {
  '192.168.33.10': "/etc/certificates/192_168_33_10.crt",
  '192.168.33.11': "/etc/certificates/192_168_33_11.crt",
  '192.168.33.12': "/etc/certificates/192_168_33_12.crt",
}
set :nginx_key_paths, {
  '192.168.33.10': "/etc/certificates/192_168_33_10.key",
  '192.168.33.11': "/etc/certificates/192_168_33_11.key",
  '192.168.33.12': "/etc/certificates/192_168_33_12.key",
}

Note: configuration key name changes from *_path to *_paths

Usage

$ bundle exec cap production deploy:setup_config
$ bundle exec cap production deploy

Contributing

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.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details