Deploy.RB / Deploy Tool
This is a part of the Deploy.RB project.
Deploy.RB consists of:
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.
Deploy of an example project "Rails 5 App"
How to deploy Rails 5 App
1. Clone the Deploy Tool and install gems
git clone https://github.com/DeployRB/DeployTool.git 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
4. Check and Edit important templates & config files
DEPLOY_ENV=production ruby deploy.rb
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 firstname.lastname@example.org edit /etc/nginx/nginx.conf
Add the line with
See example image![pic](docs/images/5.png)
Save and Exit
7. Restart NginX
DEPLOY_ENV=production ruby deploy.rb nginx_restart
rake task on the server
DEPLOY_ENV=production ruby deploy.rb rake_task db:seed
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
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!
deploy! provides deployment process in procedure-like style. You will not find here
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.rbmain 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.)
kitfolder with methods to provide a deployment process
kit/basecommon methods to provide a deployment process
kit/railsmethods to provide a deployment process for Rails app
Execution of specific methods
To execute specific a method you can use the following way:
DEPLOY_ENV=ENVIRONMENT ruby deploy.rb METHOD_NAME
ENVIRONMENT is a name of a required environment (
development by default)
METHOD_NAME is a name of a required method to execute (
deploy! by default)
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!