Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Capistrano Deploy Tasks
# Step 1: Add capistrano to Gemfile, then run `capify .`
# Step 2: create /public/assets directory locally
# Step 3: upload database.yml file to app_path/shared/config/database.yml on server
require 'bundler/capistrano'
require 'rvm/capistrano'
#server login details
set :application, "domain.com"
set :user, 'user'
set :domain, 'domain.com'
set :rvm_ruby_string, '2.0.0@gemset'
set :use_sudo, false
#version control details
set :scm, 'git'
set :repository, 'git@bitbucket.org:username/repo-name.git'
set :branch, 'master'
set :git_shallow_clone, 1
ssh_options[:forward_agent] = true
# roles (servers)
role :web, domain
role :app, domain
role :db, domain, :primary => true
# deploy config
set :deploy_to, "/home/deploy/apps/app_directory"
set :deploy_via, :remote_cache
# Passenger
namespace :deploy do
task :start do ; end
task :stop do ; end
task :config_symlink do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/assets #{release_path}/public/assets"
end
task :assets do
system "rsync -vr --exclude='.DS_Store' public/assets #{user}@#{application}:#{shared_path}/"
end
desc "Tell Passenger to restart"
task :restart, :roles => :web do
run "touch #{deploy_to}/current/tmp/restart.txt"
end
end
after "deploy:update_code", "deploy:config_symlink"
after "deploy:update_code", "deploy:assets"
after "deploy", "deploy:cleanup"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment