Skip to content

Instantly share code, notes, and snippets.

@alnutile
Created July 8, 2013 09:53
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 alnutile/5947574 to your computer and use it in GitHub Desktop.
Save alnutile/5947574 to your computer and use it in GitHub Desktop.
Capistrano Recipes. Many thanks to http://railscasts.com/episodes/337-capistrano-recipes
<VirtualHost *:80>
ServerName <%= domain %>
DocumentRoot /var/www/<%= application %>/app/current/
<Directory /var/www/<%= application %>/app/current/>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
namespace :apachevhost do
desc "Setup an apache vhost"
task :setup, roles: :web do
template "apache_vhost.erb", "/tmp/apache_vhost"
run "#{sudo} mv /tmp/apache_vhost /etc/apache2/sites-available/#{application}"
run "#{sudo} a2ensite #{application}"
run "#{sudo} service apache2 reload"
end
end
def template(from, to)
erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
put ERB.new(erb).result(binding), to
end
def set_default(name, *args, &block)
set(name, *args, &block) unless exists?(name)
end
namespace :deploy do
desc "Install everything onto the server"
task :install do
run "#{sudo} apt-get -y update"
#run "#{sudo} apt-get -y install python-software-properties"
end
end
require "bundler/capistrano"
load "config/recipes/base"
load "config/recipes/apachevhost"
server "##.##.##.##", :web, :app, :db, primary: true
set :user, "someuser"
set :domain, "example.stagingarea.us"
set :application, "captests"
set :deploy_to, "/var/www/#{application}/app"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "git@github.com:alnutile/#{application}.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment