HomeHome ArchiveArchive

Deploying Mephisto with Capistrano

load 'deploy'
require 'mongrel_cluster/recipes'

set :application, "mysite"
set :deploy_to, "/var/www/#{application}"

set :scm, :git
set :repository, "git://github.com/emk/mephisto.git"
set :branch, "v0.8-stable"
set :deploy_via, :remote_cache

set :user, "www-data"
set :use_sudo, false
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"

role :app, "myserver"
#role :web, "myserver"
role :db, "myserver", :primary => true

after 'deploy:update_code', 'deploy:finalize_update_code'
after 'deploy:rollback:revision', 'deploy:finalize_update_code'

desc "Finalize update_code"
deploy.task :finalize_update_code do
  run "cp -rf #{shared_path}/config/* #{current_release}/config/"
  run "cp -rf #{shared_path}/public/* #{current_release}/public/"
  run "rm -rf #{current_release}/public/assets; ln -s #{shared_path}/assets #{current_release}/public/assets"
  run "rm -rf #{current_release}/themes; ln -s #{shared_path}/themes #{current_release}/themes"
end

After an initial

cap deploy:setup

place the version independent data into the shared directory:

shared/assets
shared/themes/site-1/mytheme/...
shared/config/initializers/session_store.rb
shared/config/mongrel_cluster.yml
shared/config/database.yml
shared/public/favicon.ico

After that, a Mephisto update should be as simple as

cap deploy