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

Comments