Created
October 23, 2013 22:05
-
-
Save craigmcnamara/7127595 to your computer and use it in GitHub Desktop.
Capistrano 3 Rails 4 deploy example with public key auth
This file contains 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
# Gemfile | |
# | |
group :development do | |
gem 'capistrano', '~> 3.0.0' | |
gem 'capistrano-rails', '~> 0.0.7' | |
gem 'capistrano-bundler', '~> 0.0.1' | |
end | |
# Capfile | |
# | |
# Load DSL and Setup Up Stages | |
require 'capistrano/setup' | |
# Includes default deployment tasks | |
require 'capistrano/deploy' | |
# Includes tasks from other gems included in your Gemfile | |
# | |
require 'capistrano/bundler' | |
require 'capistrano/rails' | |
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. | |
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } | |
namespace :deploy do | |
desc 'Restart application' | |
task :restart do | |
on roles(:app), in: :sequence, wait: 5 do | |
# Your restart mechanism here, for example: | |
# execute :touch, release_path.join('tmp/restart.txt') | |
end | |
end | |
after :restart, :clear_cache do | |
on roles(:web), in: :groups, limit: 3, wait: 10 do | |
# Here we can do anything such as: | |
# within release_path do | |
# execute :rake, 'cache:clear' | |
# end | |
end | |
end | |
after :finishing, 'deploy:cleanup' | |
end | |
# deploy.rb | |
# | |
SSHKit.config.command_map[:rake] = "bundle exec rake" | |
set :application, 'example.com' | |
set :repo_url, 'git@github.com:craigmcnamara/site-repo.git' | |
set :ssh_options, { | |
user: 'deploy', | |
forward_agent: true, | |
auth_methods: %w(publickey) | |
} | |
set :deploy_to, '/home/deploy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment