Skip to content

Instantly share code, notes, and snippets.

@eparreno
Created March 15, 2012 17:55
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 eparreno/2045638 to your computer and use it in GitHub Desktop.
Save eparreno/2045638 to your computer and use it in GitHub Desktop.
Deploy with Capistrano + Passenger + Bundle
require "bundler/capistrano"
set :application, "myapp"
set :keep_releases, 3
# Git settings
set :scm, :git
set :repository, 'git@github.com:my_github_user/my_app.git'
set :branch, 'master'
set :copy_strategy, :export
set :deploy_via, :remote_cache
set :repository_cache, "/var/cache/www/#{application}"
#set :git_shallow_clone, 1
#set :git_enable_submodules, 1
#set :scm_verbose true
# SSH settings
set :user, 'ssh_user'
set :password, 'ssh_password'
set :use_sudo, false
set :port, '22'
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
# Roles
task :production do
set :rails_env, 'production'
set :deploy_to, "/home/rails/apps/#{application}/production"
role :web, '0.0.0.0'
role :app, '0.0.0.0'
role :db, '0.0.0.0', :primary => true
end
task :staging do
set :rails_env, 'staging'
set :deploy_to, "/home/rails/apps/#{application}/staging"
role :web, '0.0.0.0'
role :app, '0.0.0.0'
role :db, '0.0.0.0', :primary => true
end
namespace :deploy do
desc 'Restart Passenger'
task :restart, :roles => :app do
run "touch #{release_path}/tmp/restart.txt"
end
desc 'create symlinks'
task :create_symlinks, :roles => :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/uploads/ #{release_path}/public/uploads"
run "ln -nfs #{shared_path}/bundle/ #{release_path}/vendor/bundle"
end
desc 'run bundle install'
task :bundle_install, :roles => :app do
run "cd #{current_path} && bundle install --deployment --path #{shared_path}/bundle"
end
end
after "deploy:symlink", "deploy:create_symlinks", "deploy:bundle_install"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment