Skip to content

Instantly share code, notes, and snippets.

@blackcoat
Forked from gabetax/deploy.rb
Created May 4, 2012 18:53
Show Gist options
  • Save blackcoat/2596953 to your computer and use it in GitHub Desktop.
Save blackcoat/2596953 to your computer and use it in GitHub Desktop.
Capistrano deploy.rb for Rails 3.2 apps
# http://gembundler.com/deploying.html
require 'bundler/capistrano'
# http://guides.rubyonrails.org/asset_pipeline.html
load 'deploy/assets'
# http://beginrescueend.com/integration/capistrano/
# Also add rvm-capistrano to your Gemfile
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_type, :system # Copy the exact line. I really mean :system here
# If using airbrake / hop toad
# require 'airbrake/capistrano'
set :application, "THE-PROJECT-NAME"
set :repository, "ssh://[email protected]/THE-CLIENT/#{application}.git"
set :scm, :git
set :deploy_via, :remote_cache
set :use_sudo, false
set :group_writable, false # Setting $HOME to g+w during deploy:setup will break ssh key authentication
# Create additional tasks for each environment, so you may run `cap staging deploy`
task :staging do
server 'THE-SERVER.mudbugmedia.com', :web, :app, :db, :primary => true
set :deploy_to, '/www/THE-HOSTNAME'
set :user, 'THE-HOSTNAME'
set :rails_env, 'staging'
set :branch, 'master'
end
desc 'Create the shared/config dir for various config files'
task :create_configs do
run "mkdir -p #{shared_path}/config"
run "touch #{shared_path}/config/database.yml"
end
desc 'Copy the shared config files to the release config dir'
task :update_configs do
run "cp -Rf #{shared_path}/config/* #{release_path}/config"
end
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
# Set up our callbacks
after 'deploy:setup', :create_configs
after 'deploy:finalize_update', :update_configs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment