|
# |
|
# This deployment recipe assumes public keys are in use and that `mtr generate_config` |
|
# has been run on the sever. This eliminates any need for passwords to be stored or typed |
|
# in. |
|
# |
|
|
|
require 'mt-capistrano.rb' # use local copy instead of mt-capistrano gem |
|
|
|
# Configure this... |
|
set :site, "" # e.g. 12345 |
|
set :application, "" # e.g. myblog |
|
set :webpath, "" # e.g. myblog.com |
|
set :git_user, "" # bjeanes (github url taken from this + application -- change this below) |
|
|
|
# Shouldn't have to change anything below (except repository details if different...) |
|
set :domain, "s#{site}.gridserver.com" |
|
set :user, "serveradmin%#{webpath}" |
|
|
|
# Other options |
|
ssh_options[:username] = user |
|
ssh_options[:forward_agent] = true |
|
default_run_options[:pty] = true |
|
set :use_sudo, false # MediaTemple don't allow sudo command |
|
|
|
|
|
# Repo stuff |
|
set :scm, :git |
|
set :repository, "[email protected]:#{git_user}/#{application}.git" |
|
set :deploy_to, "/home/#{site}/containers/rails/#{application}" |
|
set :current_deploy_dir, "#{deploy_to}/current" |
|
set :deploy_via, :remote_cache |
|
set :tmp_dir, "#{deploy_to}/tmp" |
|
set :branch, "master" |
|
set :git_enable_submodules, 1 |
|
|
|
set :checkout, "export" |
|
|
|
# Roles |
|
role :web, domain |
|
role :app, domain |
|
role :db, domain, :primary => true |
|
|
|
# Tasks |
|
namespace :deploy do |
|
desc "Upload the database.yml file to the shared folder." |
|
task :upload_database_yml do |
|
yml = 'config/database.yml.mt' |
|
|
|
if File.exists?(yml) |
|
put(File.read(yml), "#{shared_path}/database.yml", :mode => 0644) |
|
else |
|
puts "Create #{yml} then re-run `cap deploy:upload_database_yml` before proceeding..." |
|
end |
|
end |
|
|
|
after "deploy:cold", "mt:create_link" |
|
after "deploy:start", "mt:generate_htaccess" |
|
after "deploy:restart", "mt:generate_htaccess" |
|
|
|
before "deploy:symlink" do |
|
run "rm -drf #{release_path}/public/uploads" |
|
run "ln -s #{shared_path}/uploads #{release_path}/public/uploads" |
|
run "rm -f #{release_path}/config/database.yml" |
|
run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml" |
|
end |
|
|
|
after "deploy:setup" do |
|
upload_database_yml |
|
mt.add |
|
end |
|
end |