Posted 8 months 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:

Copy
. ├── 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:

Copy
# 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 [] # If we are managing your secrets.yml, the following should be set to %w(config/database.yml config/secrets.yml) set :linked_files, %w(config/database.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:

Copy
# 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 'app01-test.demo.makandra.de', user: 'deploy-cap-demo_s', roles: %w(app web cron db) # first is primary server 'app02-test.demo.makandra.de', user: 'deploy-cap-demo_s', roles: %w(app web)

Almost identical would be the example for production:

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

Owner of this card:

Avatar
Marius Schuller
Last edit:
8 months ago
by Stefan Langenmaier
Posted by Marius Schuller to opscomplete
This website uses cookies to improve usability and analyze traffic.
Accept or learn more