This is a part of the Deploy.RB project.
Deploy.RB consists of:
- Rails 5 App
- Server Installation Script & Manual
- Deployment Tool (You are here)
Please, visit Deploy.RB page to get more information.
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.
How to deploy Rails 5 App
git clone https://github.com/DeployRB/DeployTool.git
cd DeployTool
gem install bundler
bundle install
cp -Rv __ENV__/production.example __ENV__/production
EDIT: __ENV__/production/__SETTINGS__/server_access.yml
EDIT: __ENV__/production/__SETTINGS__/database.yml
EDIT: __ENV__/production/__SETTINGS__/deploy_params.yml
EDIT: __ENV__/production/__TEMPLATES__/settings/app.yml
DEPLOY_ENV=production ruby deploy.rb
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@257.123.45.67
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
DEPLOY_ENV=production ruby deploy.rb nginx_restart
DEPLOY_ENV=production ruby deploy.rb rake_task
db:seed
See example image
![pic](docs/images/8.png)The Entry point of the project is method deploy!
in file kit/rails/deploy.rb
Method deploy!
looks like this:
def deploy!
startup_authorize_deployer
startup_create_base_dirs
startup_copy_ssh_files
...
app_bundle
app_database_create
app_database_migrate
app_assets_precompile
link_current_release
puma_restart
release_cleanup
end
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!
├── __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 processkit/base
common methods to provide a deployment processkit/rails
methods to provide a deployment process for Rails app
To execute specific a method you can use the following way:
DEPLOY_ENV=ENVIRONMENT ruby deploy.rb METHOD_NAME
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)
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!