Last active
August 29, 2015 14:18
-
-
Save lesterzone/83af61314c0942504a4a to your computer and use it in GitHub Desktop.
Deploy Ruby on Rails API with Capistrano and RVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load DSL and set up stages | |
require 'capistrano/setup' | |
# Include default deployment tasks | |
require 'capistrano/deploy' | |
require 'capistrano/rvm' | |
# Load custom tasks from `lib/capistrano/tasks' if you have any defined | |
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
role :app, %w{YOUR-HOST-NAME-OR-IP} | |
role :web, %w{YOUR-HOST-NAME-OR-IP} | |
role :db, %w{YOUR-HOST-NAME-OR-IP} | |
server 'YOUR-HOST-NAME-OR-IP', user: 'USER-ON-SERVER', roles: %w{web app} | |
set :ssh_options, { | |
keys: %w(~/.ssh/id_rsa), | |
forward_agent: true, | |
auth_methods: %w(publickey) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config valid only for current version of Capistrano | |
lock '3.4.0' | |
set :application, 'YOUR APP NAME' | |
set :branch, :development | |
set :repo_url, '[email protected]:USERNAME/REPO-NAME.git' | |
set :pty, true | |
set :default_env, { | |
'PATH' => "/home/USER/.rvm/gems/ruby-2.2.0/bin:/home/USER/.rvm/bin:$PATH", | |
'RUBY_VERSION' => 'ruby-2.2.0', | |
'GEM_HOME' => '/home/USER/.rvm/gems/ruby-2.2.0', | |
'GEM_PATH' => '/home/USER/.rvm/gems/ruby-2.2.0', | |
'BUNDLE_PATH' => '/home/USER/.rvm/gems/ruby-2.2.0' # If you are using bundler. | |
} | |
# Default deploy_to directory is /var/www/my_app_name | |
set :deploy_to, '/home/USER/YOUR-APP-FOLDER' | |
# Default value for :linked_files is [] | |
set :linked_files, fetch(:linked_files, []). | |
push('config/DATABASE-CONFIG.yml', 'config/secrets.yml') | |
# Default value for linked_dirs is [] | |
set :linked_dirs, fetch(:linked_dirs, []). | |
push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets') | |
# Default value for keep_releases is 5 | |
set :keep_releases, 5 | |
namespace :deploy do | |
task :install_dependencies do | |
on roles(:web), in: :sequence, wait: 5 do | |
within release_path do | |
execute :bundle, "--without development test" | |
end | |
end | |
end | |
after :published, :install_dependencies | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
# Deploy | |
gem 'capistrano', '~> 3.4.0' | |
gem 'capistrano-rvm' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment