Dreamhost/Capistrano confusion

Ingo Weiss 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)