Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Created December 13, 2013 00:23
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 juliocesar/7938048 to your computer and use it in GitHub Desktop.
Save juliocesar/7938048 to your computer and use it in GitHub Desktop.
# Capistrano deployment file
# ==========================
#
# Deployment requires that you can log in as "web", which means you'll
# need it's password.
require 'bundler/capistrano'
set :rvm_ruby_string, :local # Use the same ruby as used locally for deployment
set :rvm_autolibs_flag, "read-only" # More info: rvm help autolibs
before 'deploy:setup', 'rvm:install_rvm' # Install RVM
before 'deploy:setup', 'rvm:install_ruby' # Install Ruby and create gemset, OR:
before 'deploy:setup', 'rvm:create_gemset' # Only create gemset
require 'rvm/capistrano'
load 'deploy'
set :application, 'app-name'
set :deploy_to, '/path/to/where/app/will/live'
set :user, 'web'
set :scm, :none
set :repository, '.'
set :deploy_via, :copy
set :use_sudo, false
set :app_server, :passenger
server 'xxx.xxx.xxx.xxx', :app, :web
namespace :gems do
desc 'Runs bundler'
task :bundler do
run "cd #{current_path} && RAILS_ENV=production bundle install --deployment"
end
end
namespace :deploy do
desc 'Creates APP/tmp dir'
task :create_tmp do
run "mkdir -p #{current_path}/tmp"
end
desc 'Copies the database config into place'
task :copy_db_config do
run "cp ~/database.yml #{current_path}/config/database.yml"
end
desc 'Restarts Apache'
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
desc 'Ensures site is enabled and starts Apache'
task :start do
sudo 'a2ensite lector.io'
sudo 'apache2ctl graceful'
end
desc 'Disables the virtual host'
task :stop do
sudo 'a2dissite lector.io'
sudo 'apache2ctl graceful'
end
desc 'Compiles assets'
task :compile_assets do
run "RAILS_ENV=production bundle exec rake assets:precompile"
end
end
after "deploy:symlink",
"deploy:compile_assets",
"deploy:create_tmp", "deploy:copy_db_config", "gems:bundler"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment