Permalink
Browse files

Added deploy recipe for capistrano.

  • Loading branch information...
1 parent 76e6371 commit 40d53954497dd50641b8175cd94a214b156cbfe1 @traviskroberts traviskroberts committed May 7, 2010
Showing with 99 additions and 0 deletions.
  1. +4 −0 Capfile
  2. +95 −0 config/deploy.rb
View
@@ -0,0 +1,4 @@
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
+
+load 'config/deploy' # remove this line to skip loading any of the default tasks
View
@@ -0,0 +1,95 @@
+set :stages, %w(production)
+require 'capistrano/ext/multistage'
+
+set :application, "donatenashvill.org"
+set :domain, "beta.donatenashville.org"
+set :server_path, "/var/www"
+set :deploy_to, "#{server_path}/#{application}"
+
+set :scm, :git
+set :repository, "git@github.com:bshaffer/Donate-Nashville.git"
+
+set :symfony_lib, "/usr/local/lib/symfony"
+set :symfony_version, 'RELEASE_1_4_4'
+
+set :app_symlinks, %w{uploads}
+
+# =============================================================================
+# CAPISTRANO OPTIONS
+# =============================================================================
+set :user, 'donatenash'
+set :use_sudo, false
+set :keep_releases, 3
+set :deploy_via, :remote_cache
+
+# =============================================================================
+# OVERWRITE TASKS
+# =============================================================================
+namespace :deploy do
+ desc 'Overwrite the start task to set the permissions on the project.'
+ task :start do
+ run "php #{release_path}/symfony project:permissions"
+ end
+
+ desc 'Overwrite the restart task because we dont need it.'
+ task :restart do ; end
+
+ desc 'Overwrite the stop task because we dont need it.'
+ task :stop do ; end
+
+ desc 'Customize migrate task to work with symfony.'
+ task :migrate do
+ run "php #{release_path}/symfony doctrine:migrate --env='prod'"
+ end
+
+ desc 'Symlink static directories.'
+ task :create_dirs do
+ if app_symlinks
+ app_symlinks.each do |link|
+ run "mkdir -p #{shared_path}/system/#{link}"
+ run "ln -nfs #{shared_path}/system/#{link} #{release_path}/web/#{link}"
+ end
+ end
+ end
+
+ desc 'Customize the finalize_update task to work with symfony.'
+ task :finalize_update, :except => { :no_release => true } do
+ run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
+
+ run <<-CMD
+ rm -rf #{latest_release}/log #{latest_release}/web/system #{latest_release}/cache &&
+ mkdir -p #{shared_path}/cache &&
+ ln -s #{shared_path}/log #{latest_release}/log &&
+ ln -s #{shared_path}/system #{latest_release}/web/system &&
+ ln -s #{shared_path}/cache #{latest_release}/cache
+ CMD
+
+ if fetch(:normalize_asset_timestamps, true)
+ stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S")
+ asset_paths = %w(css images js).map { |p| "#{latest_release}/web/#{p}" }.join(" ")
+ run "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" }
+ end
+ end
+end
+
+namespace :symlink do
+ desc "Symlink the database"
+ task :db do
+ run "ln -nfs #{shared_path}/system/databases.yml #{release_path}/config/databases.yml"
+ end
+
+ desc 'Symlink the symfony library.'
+ task :symfony do
+ run "ln -nfs #{symfony_lib}/#{symfony_version} #{release_path}/lib/symfony"
+ end
+end
+
+namespace :symfony do
+ desc 'Task to clear the cache on deploy.'
+ task :clear_cache do
+ run "php #{release_path}/symfony cache:clear"
+ end
+end
+
+after 'deploy:finalize_update', 'symlink:symfony', 'deploy:create_dirs', 'symfony:clear_cache'
+after 'deploy:symlink', 'symlink:db'

0 comments on commit 40d5395

Please sign in to comment.