Skip to content

Instantly share code, notes, and snippets.

@nocksock
Created Dec 7, 2011
Embed
What would you like to do?
Capistrano Drupal(6) Deployment Recipe
#
# Capistrano recipe for deploying Drupal7 using git and ssh.
#
# Part of the explanations in the comments taken from:
# http://help.github.com/deploy-with-capistrano/
#
set :default_environment, {
# This is the $PATH for the deploymant shell. using uberpsace's recent php
# and added ~/bin for drush.
'PATH' => "$HOME/bin/:/package/host/localhost/php-5/bin/:$PATH:"
}
set :domain , "vortrieb.net"
set :user , "vortrieb"
set :application , "Vortrieb.net Website"
set :repository , "git@github.com:Vortrieb/Vortrieb.net.git"
# This is where the currentshared and releases folder will be created.
set :deploy_to , "/var/www/virtual/#{user}/"
# delete all but the last n releases.
set :keep_releases , 4
set :use_sudo , false
set :scm , :git
set :branch , "master"
set :scm_verbose , true
# Remote caching will keep a local git repo on the server you’re deploying to
# and simply run a fetch from that rather than an entire clone. This is
# probably the best option as it will only fetch the changes since the last.
# In most cases you want to use this option, otherwise each deploy will do
# a full repository clone every time.
set :deploy_via, :remote_cache
# If you’re using git submodules you must tell cap to fetch them.
set :git_enable_submodules, 1
# we're using private keys, so capistrano should use 'em too.
ssh_options[:forward_agent] = true
# Must be set for the password prompt from git to work
default_run_options[:pty] = true
# we only need one role
role :website, domain, :primary => true
# register the callbacks
after 'deploy:setup' , 'drupal:setup'
after 'deploy:symlink' , 'drupal:symlink'
after 'deploy' , 'drupal:clear_cache'
# override default tasks that wont apply to drupal/php
namespace :deploy do
task :set_permissions do
# noop
end
task :restart do
# noop
end
task :start do
# noop
end
end
namespace :drupal do
# create shared files-directory
task :setup do
run "mkdir -p #{shared_path}/files"
end
# symlink shared directories
task :symlink do
run "ln -s #{shared_path}/files #{latest_release}/sites/default/files"
end
# CLEAR ALL THE CACHES!
# expect drush to be in $PATH
task :clear_cache do
run "cd #{latest_release} && drush cc all"
end
end
# vim: set ts=8 sw=2 tw=79 cc=80 ft=ruby:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment