Here’s my recipe to get a source tree commited into subversion, then setup Capistrano and then deploy the application on a production server.
I’ve done this many times, and everytime I stumble of one or more steps to find find what comes next, what path to use, etc. So here’s a note to hopefully settle this once and for all.
Assumes that the subversion database is created on domain.net under /home/psq/svn/domainsvn. Assumes that the initial “domain” directory contains trunk, tags and branches and that you are deploying the trunk.
cd domain
svn import . svn+ssh://domain.net/home/psq/svn/domainsvn
mkdir domainsvn
cd domainsvn
svn co svn+ssh://domain.net/home/psq/svn/domainsvn/trunk .
cap -A .
svn add config/deploy.rb
svn add lib/tasks/capistrano.rake
edit deploy.rb
And initialize user, application, repository…
set :use_sudo, false
set :user, ‘psq’
set :application, “domain.net”
set :repository, “svn+ssh://domain.net/home/#{user}/svn/domainsvn/trunk”
set :deploy_to, “/home/#{user}/#{application}”
Replace defaulf roles
role :web, application
role :app, application
role :db, application, :primary => true
Add at the end of deploy.rb. See A better alternative to killall for details.
desc “Restart the FCGI processes on the app server as a regular user.”
task :restart, :roles => :app do
run “pkill -9 -u #{user} ruby”
end
Now you are ready for the first deployment.
rake remote:exec ACTION=setup
And finally, to deploy:
cap deploy [or]
cap -q deploy (for quiet output)
If you you use “migration”, as you should, to create the tables on the remote host, and every time you update the tables:
rake remote:migrate
This assumed that your app was fully configured to work in your hosting environment. And if you haven’t done that yet, now if the time to do it.