Posted over 2 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 # It might be helpful to set the deploy user as well set :user, 'deploy-cap-demo_s' 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)

Owner of this card:

Marius Schuller
Last edit:
about 1 year ago
by Claus-Theodor Riegg
Posted by Marius Schuller to opscomplete
This website uses short-lived cookies to improve usability.
Accept or learn more