Created
July 8, 2013 09:53
-
-
Save alnutile/5947574 to your computer and use it in GitHub Desktop.
Capistrano Recipes. Many thanks to http://railscasts.com/episodes/337-capistrano-recipes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName <%= domain %> | |
DocumentRoot /var/www/<%= application %>/app/current/ | |
<Directory /var/www/<%= application %>/app/current/> | |
AllowOverride all | |
Options -MultiViews | |
</Directory> | |
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, "[email protected]: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