Add capistrano deploy scripts and staging database configuration params

1.0
Fernando Espinosa 14 years ago
parent bd49e6e41a
commit d2e3d60a58

@ -0,0 +1,4 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks

@ -12,6 +12,8 @@ gem 'rails_warden'
gem 'rdoc', :group => :development
gem 'passenger', :group => :development
gem 'capistrano'
gem 'capistrano-ext'
group :test, :development do
gem 'mocha'

@ -49,6 +49,14 @@ GEM
archive-tar-minitar (0.5.2)
arel (2.0.7)
builder (2.1.2)
capistrano (2.5.19)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
capistrano-ext (1.2.1)
capistrano (>= 1.0.0)
capybara (0.4.0)
celerity (>= 0.7.9)
culerity (>= 0.2.4)
@ -73,6 +81,7 @@ GEM
rake (>= 0.8.7)
file-tail (1.0.5)
spruz (>= 0.1.0)
highline (1.6.1)
i18n (0.5.0)
json_pure (1.4.6)
launchy (0.3.7)
@ -89,6 +98,13 @@ GEM
mocha (0.9.10)
rake
multi_json (0.0.5)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.1.0)
net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1)
nofxx-georuby (1.9.0)
json_pure (>= 1.4.6)
nokogiri (1.4.4)
@ -173,6 +189,8 @@ PLATFORMS
ruby
DEPENDENCIES
capistrano
capistrano-ext
capybara
capybara-zombie!
launchy

@ -0,0 +1,61 @@
require 'capistrano/ext/multistage'
set :stages, %w(staging production)
set :default_stage, "staging"
require "bundler/capistrano"
default_run_options[:pty] = true
set :application, 'cartodb'
set :scm, :git
# set :git_enable_submodules, 1
set :git_shallow_clone, 1
set :scm_user, 'ubuntu'
set :use_sudo, false
set :repository, "git@github.com:Vizzuality/cartodb.git"
ssh_options[:forward_agent] = true
ssh_options[:keys] = [File.join(ENV["HOME"], ".ec2", "id-vizzuality")]
set :keep_releases, 5
set :linode_staging, '184.73.254.217'
set :linode_production, '184.73.254.217'
set :user, 'ubuntu'
set(:deploy_to){
"/home/ubuntu/www/#{stage}.#{application}.com"
}
after "deploy:update_code", :run_migrations, :symlinks, :asset_packages, :set_staging_flag
desc "Restart Application"
deploy.task :restart, :roles => [:app] do
run "touch #{current_path}/tmp/restart.txt"
end
desc "Migraciones"
task :run_migrations, :roles => [:app] do
run <<-CMD
export RAILS_ENV=production &&
cd #{release_path} &&
rake db:migrate
CMD
end
task :symlinks, :roles => [:app] do
run <<-CMD
ln -s #{shared_path}/system #{release_path}/public/system;
ln -s #{shared_path}/pdfs #{release_path}/public/;
ln -s #{shared_path}/cache #{release_path}/public/;
CMD
end
desc 'Create asset packages'
task :asset_packages, :roles => [:app] do
run <<-CMD
export RAILS_ENV=#{stage} &&
cd #{release_path} &&
rake asset:packager:build_all
CMD
end

@ -0,0 +1,8 @@
role :app, linode_production
role :web, linode_production
role :db, linode_production, :primary => true
set :branch, "production"
task :set_staging_flag, :roles => [:app] do
end

@ -0,0 +1,12 @@
role :app, linode_staging
role :web, linode_staging
role :db, linode_staging, :primary => true
set :branch, "staging"
task :set_staging_flag, :roles => [:app] do
run <<-CMD
cd #{release_path} &&
touch STAGING
CMD
end
Loading…
Cancel
Save