My latest capistrano deploy.rb file using a deploy_via :copy

This is the approach I’ve been taking to my smaller sites that I just work on myself. I keep the site locally gitified on my computer and avoid posting to github.

It makes things super simple for those sole freelance projects, and as long as you keep your computer backed up you’re fine.

Just change lines 1,11,12,13,29, and 40.

 1 set :runner, "username"
       2 set :use_sudo, false
       3 
       4 # =============================================================================
       5 # CUSTOM OPTIONS
       6 # =============================================================================
       7 set :user, "username"
       8 set :application, "yourapp"
       9 set :domain, "yourdoman.com"
      10 
      11 role :web, domain
      12 role :app, domain
      13 role :db,  domain, :primary => true
      14 
      15 # =============================================================================
      16 # DATABASE OPTIONS
      17 # =============================================================================
      18 set :rails_env,       "production"
      19 
      20 # =============================================================================
      21 # DEPLOY TO
      22 # =============================================================================
      23 set :deploy_to, "/home/#{user}/apps/#{application}"
      24 
      25 # =============================================================================
      26 # REPOSITORY
      27 # =============================================================================
      28 set :scm, "git"
      29 set :repository,  "/Users/scottmotte/Documents/code/rails/#{application}"
      30 set :branch, "master"
      31 set :deploy_via, :copy
      32 set :copy_exclude, [".svn", ".git"]
      33 
      34 # =============================================================================
      35 # SSH OPTIONS
      36 # =============================================================================
      37 
      38 default_run_options[:pty] = true
      39 ssh_options[:paranoid] = false
      40 ssh_options[:keys] = %w(/Users/scottmotte/.ssh/id_rsa)
      41 ssh_options[:port] = 1985
      42 
      43 
      44 # =============================================================================
      45 # RAKE TASKS & OTHER SERVER TASKS
      46 # =============================================================================
      47 
      48 # desc 'Fix attachment_fu'
      49 # task :fix_attachment_fu, :roles => :app do
      50 #   %w{attachments}.each do |share|
      51 #     run "rm -rf #{release_path}/public/#{share}"
      52 #     run "mkdir -p #{shared_path}/system/#{share}"
      53 #     run "ln -nfs #{shared_path}/system/#{share} #{release_path}/public/#{share}"
      54 #   end
      55 # end
      56 
      57 desc "Create symlink to public_html/#{domain}/public"
      58 task :symlinkify do
      59   run "rm -rf /home/#{user}/public_html/#{domain}/public; ln -s #{current_path}/public /home/#{user}/public_html/#{domain}"
      60 end
      61 
      62 desc "Reload Apache"
      63 task :reload_apache do
      64   sudo "/etc/init.d/apache2 reload"
      65 end
      66 
      67 # doesn't work yet, but would be good to add.
      68 # desc 'Install all gems'
      69 # task :rake_gems, :roles => :app do
      70 #   run "cd #{release_path}"
      71 #   run "rake gems:install"
      72 # end
      73 
      74 after "deploy", "deploy:migrations"
      75 after "deploy:migrations", "deploy:cleanup"
      76 after "deploy:cleanup", "symlinkify"
      77 after "symlinkify", "reload_apache"
      

Picture of Scott Motte

delicious facebook rss twitter

Spitfire Sky | github | archives | resume