Skip to content

Instantly share code, notes, and snippets.

@FernandoEscher
Created June 20, 2012 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FernandoEscher/2960054 to your computer and use it in GitHub Desktop.
Save FernandoEscher/2960054 to your computer and use it in GitHub Desktop.
Capistrano deployment script
set :rvm_ruby_string, '1.9.3-p0@ccepreb'
set :rvm_install_type, :stable
set :rvm_install_ruby, :install
require "rvm/capistrano"
# server details
default_run_options[:pty] = true
set :application, "your_app"
server "ip_or_domain", :app, :web, :db, :primary => true
set :deploy_to, "/path/to/your/project"
set :user, "your_user"
set :use_sudo, false
# repo details
set :repository, "git@git_repo.com"
set :scm, :git
set :scm_user, "server_user"
set :branch, "master"
set :git_enable_submodules, 1
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do
run "#{try_sudo} touch #{File.join(current_release,'tmp','restart.txt')}"
end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_release,'tmp','restart.txt')}"
end
end
namespace :assets do
task :precompile, :roles => :web do
run "cd #{current_release} && RAILS_ENV=production bundle exec rake assets:precompile"
end
task :cleanup, :roles => :web do
run "cd #{current_release} && RAILS_ENV=production bundle exec rake assets:clean"
end
end
namespace :gems do
desc "Install gems"
task :install, :roles => :app do
run "cd #{current_release} && bundle install"
end
end
namespace :deploy do
desc "reload the database with seed data"
task :seed do
run "cd #{current_release} && rake db:seed RAILS_ENV=production"
end
end
after "deploy:update_code", "gems:install"
after 'deploy', "assets:precompile"
after 'deploy:migrate', 'deploy:seed'
before 'deploy:setup', 'rvm:install_rvm'
before 'deploy:setup', 'rvm:install_ruby'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment