Dreamhost/Capistrano confusion

Hi,

I am having trouble getting a Rails app deployed on Dreamhost via
Capistrano. I am using the information from the Dreamhost wiki at
http://wiki.dreamhost.com/index.php/Ruby_on_Rails, and the ‘shovel
dreamhost’ script from nubyonrails.com/pages/shovel_dreamhost. One of my
problems is that the wiki seems to suggest to create the app on the
production server, do the dreamhost-specific configuration and then just
copy over the ‘app’ folder (and a couple more) from development. However
the capistrano script seems to export the entire folder from subversion.
(BTW I froze the app to edge rails - does this make a difference?).

I was wondering whether any of the list members has found a workflow for
developing apps locally and deploying them on Dreamhost that actually
works.

Thanks!
Ingo

Ingo W. wrote:

I was wondering whether any of the list members has found a workflow for
developing apps locally and deploying them on Dreamhost that actually
works.

Hi Ingo,

This should cover everything you need to set up. I use separate live
and staging environments, so I’ve included those settings in case you
find it helpful.

  1. Make your deploy.rb and other files on your local development
    machine and commit them to Svn.

  2. Use DH panel to set your hosted directory to app_name/current/public

  3. Empty out the “app_name” directory where you will be deploying to.
    then run cap setup so it creates the current/shared/releases
    directories and symlinks in there.

  4. Run cap deploy.

Here’s what I have in my config files:

config/deploy.rb

set :application, “your_app”
set :user, ‘your_user’
set :svn_username, “your_svn_username”
set(:svn_password) { Capistrano::CLI.password_prompt } # (don’t know
if CLI.password is necessary)
set :repository, “http://svn.your_domain.com/trunk”
set :use_sudo, false
set :checkout, “export”

for ssh key-based passwordless connection (optional)

ssh_options[:keys] =
%w(’/Users/your_local_dev_machine_user/.ssh/id_dsa’)

for separate staging / live environments (optional)

case ENV[‘TO’]
when ‘production’ :
set :deploy_to, “/home/#{user}/#{application}”
set :rails_env, :production
else
set :deploy_to, “/home/#{user}/stage.#{application}”
set :rails_env, :staging
end

roles

role :app, application
role :web, application, :no_release => true
role :db, application, :primary => true, :no_release => true

tasks

desc “Restart the FCGI processes on the app server as a regular user.”
task :restart, :roles => :app do
run “#{current_path}/script/process/reaper -d dispatch.fcgi”
end

for this you should symlink whatever directories you want kept in

current between deployments which aren’t stored in SVN.

desc “Link shared files to carry them forward to current deployment”
task :before_symlink do
run “rmdir #{current_release}/public/uploads”
run “ln -nfs #{deploy_to}/#{shared_dir}/uploads”
" #{current_release}/public/"
end

config/environment.rb

Set environment based on deployment directory name (optional)

(I use a directory name without .com for local development)

case File.expand_path(’…/…/…’,Dir.pwd).gsub(/.*//,’’)
when ‘your_app.com’ : ENV[‘RAILS_ENV’] = ‘production’
when ‘stage.your_app.com’ : ENV[‘RAILS_ENV’] = ‘staging’
end

config/environments/staging.rb

create this file as needed for logging/error reporting settings for

your staging environment. (optional)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs