Posted over 3 years ago. Visible to the public.

Capistrano: Configure Capistrano

If you followed this guide, you will have already executed bundle exec cap install STAGES=staging,production and your project directory will look something like this:

. ├── Capfile ├── config │ ├── deploy │ │ ├── production.rb │ │ └── staging.rb │ └── deploy.rb ├── Gemfile └── lib └── capistrano └── tasks

Starting from there, we at makandra use the following changes to the config/deploy.rb file ourselves:

# config/deploy.rb abort 'You must run this using "bundle exec ..."' unless ENV['BUNDLE_BIN_PATH'] || ENV['BUNDLE_GEMFILE'] set :application, 'YOUR_APPLICATION_NAME' set :scm, :git set :repo_url, 'YOUR_PROJECTS_GIT_REPO_URL' # Default value for :log_level is :debug set :log_level, :info # %i(debug info error), default: :debug # Default value for :linked_files is [] set :linked_files, %w(config/database.yml config/secrets.yml) # Default value for linked_dirs is [] set :linked_dirs, %w(log public/system tmp/pids) # Default value for keep_releases is 5 set :keep_releases, 10 set :ssh_options, { forward_agent: true }

The config/deploy/staging.rb and config/deploy/production.rb can be quite similar. For staging we write something like this:

# config/deploy/staging.rb set :stage, :staging set :deploy_to, 'YOUR_SERVER_DEPLOY_PATH' set :rails_env, 'staging' set :branch, ENV['DEPLOY_BRANCH'] || 'master' server '', user: 'deploy-cap-demo_s', roles: %w(app web cron db) # first is primary server '', user: 'deploy-cap-demo_s', roles: %w(app web)

Almost identical would be the example for production:

# config/deploy/production.rb set :stage, :production set :deploy_to, 'YOUR_SERVER_DEPLOY_PATH' set :rails_env, 'production' set :branch, 'production' server '', user: 'deploy-cap-demo_s', roles: %w(app web cron db) # first is primary server '', user: 'deploy-cap-demo_s', roles: %w(app web)

Usually you will need for a default rails application the following additions to your Capfile:

# Capfile require 'capistrano/bundler' require 'capistrano/rails/assets' require 'capistrano/rails/migrations'

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).

Owner of this card:

Marius Schuller
Last edit:
3 months ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Marius Schuller to opscomplete
This website uses short-lived cookies to improve usability.
Accept or learn more