Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Deploy.RB / Deploy Tool

This is a part of the Deploy.RB project.

Deploy.RB consists of:

  1. Rails 5 App
  2. Server Installation Script & Manual
  3. Deployment Tool (You are here)

Please, visit Deploy.RB page to get more information.

Deploy Tool

Simple but effective Deploy Tool is written in Ruby in procedure-oriented style.

This tool is a good choice for simple projects based on the just server and for education & demonstrative purposes.

Deploy of an example project "Rails 5 App"

How to deploy Rails 5 App

1. Clone the Deploy Tool and install gems

git clone
cd DeployTool

gem install bundler
bundle install

2. Copy templates & config files

cp -Rv __ENV__/production.example __ENV__/production

3. Set up access parameters in server_access.yml config file

EDIT: __ENV__/production/__SETTINGS__/server_access.yml

4. Check and Edit important templates & config files

EDIT: __ENV__/production/__SETTINGS__/database.yml

EDIT: __ENV__/production/__SETTINGS__/deploy_params.yml

EDIT: __ENV__/production/__TEMPLATES__/settings/app.yml

5. Deploy!

DEPLOY_ENV=production ruby deploy.rb

6. Edit NginX config file

Run command. This command will show you an address of NginX config files

DEPLOY_ENV=production ruby deploy.rb nginx_info

Go to the server and edit:

ssh root@

edit /etc/nginx/nginx.conf

Add the line with include PATH/TO/NGINX/CONFIG

See example image ![pic](docs/images/5.png)

Save and Exit

7. Restart NginX

DEPLOY_ENV=production ruby deploy.rb nginx_restart

8. Run rake task on the server

DEPLOY_ENV=production ruby deploy.rb rake_task


9. Visit the App by IP or Domain name

See example image ![pic](docs/images/8.png)

How does Deploy Tool work?

The Entry point of the project is method deploy! in file kit/rails/deploy.rb

Method deploy! looks like this:

  def deploy!






To run this method you can use the following command:

DEPLOY_ENV=production ruby deploy.rb deploy!

Method deploy! provides deployment process in procedure-like style. You will not find here after and before hooks. Everything is just a set of ruby methods. You can manage an order of an execution of the methods manually.

You can use binding.pry to stop a deployment process at any point if you want to check what specific method does.

This project uses really simple approaches and code base. You can learn how it works in minutes!

Project's stucture

├── __ENV__
│  ├── production
│  │  ├── __SETTINGS__
│  │  │  ├── database.yml
│  │  │  ├── deploy_params.yml
│  │  │  └── ssh_ssl.yml
│  │  ├── __TEMPLATES__
│  │  │  ├── database.yml
│  │  │  ├── services/*
│  │  │  ├── settings/*
│  │  │  └── ssh_ssl/*
├── deploy.rb
└── kit
    ├── base/*
    ├── common/*
    ├── custom/*
    ├── rails/*
    └── kit.rb
  • deploy.rb main entry point of Deploy Tool
  • __ENV__ Folder for keeping Settings snd Templates for a specific environment
  • __SETTINGS__ Settings for the Deploy Tool
  • __TEMPLATES__ Templates to configure external services (DB (database.yml), Redis, Sidekiq, Thinkig Sphinx, etc.)
  • kit folder with methods to provide a deployment process
  • kit/base common methods to provide a deployment process
  • kit/rails methods to provide a deployment process for Rails app

Execution of specific methods

To execute specific a method you can use the following way:


where ENVIRONMENT is a name of a required environment (development by default)

where METHOD_NAME is a name of a required method to execute (deploy! by default)

Additional params

Deploy debugging

DEPLOY_DEBUG=true will run a method, but ssh calls will not be executed

Specific release directory

DEPLOY_DIR=DIRECTORY_NAME will run a method inside a specific release folder. The list of the folders of releases you will find in the file RELEASES.txt which will be created right after a first deploy.

This option can be helpful if you want to update the code of an existed release, but don't want to re-deploy all the project.

DEPLOY_ENV=production DEPLOY_DIR=2016-10-03--23-33-14--master ruby deploy.rb deploy_backend_changes!