My deploy.rb file for my Rails application hosted at RailsPlayground.com
INTRODUCTION
This article is about how to configure Capistrano’s deploy.rb file so that it works on railsplayground.com. I’m assuming that you registered for the Guru plan with a site called “MainRegisteredDomain.com” and you are hosting another site using rails called “YourSite.com” and that you are planning to deploy to the production server. This generalized version of deploy.rb has not been tested (because it’s general—duh!), but it is based on a working version. ~/your_rails_application/config/deploy.rb resides in your local development machine.
Note: "defaultrails" is the directory of files that you get when you type in "rails defaultrails". I use this default rails installation to point to the system-specific or rails-version-specific files that need to come from the webserver's installation of rails.
Note 2: I am assuming you have removed from SVN /config/boot.rb, config/environment.rb, /config/database.yml, /config/environments/development.rb, /script/*. Once these files are removed, you can make symbolic links in those locations.
BASIC INFO
Your Site name: yoursite.com
SSH login name: mr_yoursite
The site that you used to sign up for railsplayground.com: MainRegisteredDomain.com
Name of Capistrano root directory: yoursite_production
Name of SVN repository: yoursite_repository
Name of the application directory: yoursite_production <--- this is the Capistrano root directory where, in a subdirectory called "current", Capistrano is going to deploy your code.
----- BEGIN /config/deploy.rb -----
set :user, 'mr_yoursite'
set :password, 'SECRET'
set :server, 'yoursite.com'
set :svnserver, 'MainRegisteredDomain.svnrepository.com'
set :application, 'yoursite'
set :applicationdir, 'yoursite_production'
set :repository, "http://#{svnserver}/svn/yoursite_repository/trunk"
role :web, server
role :app, server
role :db, server, :primary => true
set :deploy_to, "/home/#{user}/#{applicationdir}"
set :absolute_shared_directory, "#{deploy_to}/shared"
set :default_rails, "#{deploy_to}/shared/default_rails"
set :current_deployment, "#{deploy_to}/current"
task :restart, :roles => :app do
end
task :after_symlink do
run "ln -s #{default_rails}/config/boot.rb #{current_deployment}/config/boot.rb"
run "ln -s #{default_rails}/config/environment.rb #{current_deployment}/config/environment.rb"
run "ln -s #{absolute_shared_directory}/config/database.yml #{current_deployment}/config/database.yml"
run "ln -s #{default_rails}/config/environments/development.rb #{current_deployment}/config/environments/development.rb"
run "ln -s #{default_rails}/script #{current_deployment}/script"
run "cp -f #{default_rails}/public/dispatch.cgi #{current_deployment}/public/dispatch.cgi"
run "chmod 755 -R #{current_deployment}/public"
end
Posted by David Beckwith on Wednesday, April 25, 2007