adds capistrano's deploy configuration and scripts

This commit is contained in:
Juanjo Bazán
2015-08-07 12:17:18 +02:00
parent a0140f6dda
commit 808f0fcfbb
7 changed files with 88 additions and 6 deletions

12
Capfile Normal file
View File

@@ -0,0 +1,12 @@
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

View File

@@ -1,6 +1,5 @@
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use PostgreSQL
@@ -26,11 +25,6 @@ gem 'devise'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'acts_as_commentable_with_threading'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'acts-as-taggable-on'
gem "responders"
gem 'foundation-rails'
@@ -52,6 +46,9 @@ group :development, :test do
gem 'quiet_assets'
gem 'letter_opener_web', '~> 1.2.0'
gem 'i18n-tasks'
gem 'capistrano', '3.4.0', require: false
gem "capistrano-bundler", '1.1.4', require: false
gem "capistrano-rails", '1.1.3', require: false
end
group :test do

View File

@@ -53,6 +53,16 @@ GEM
builder (3.2.2)
byebug (5.0.0)
columnize (= 0.9.0)
capistrano (3.4.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.1.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
@@ -74,6 +84,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
colorize (0.7.7)
columnize (0.9.0)
coveralls (0.8.2)
json (~> 1.8)
@@ -145,6 +156,9 @@ GEM
mini_portile (0.6.2)
minitest (5.7.0)
multi_json (1.11.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
netrc (0.10.3)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
@@ -232,6 +246,10 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sshkit (1.7.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
term-ansicolor (1.3.2)
tins (~> 1.0)
terminal-table (1.5.2)
@@ -271,6 +289,9 @@ DEPENDENCIES
acts_as_commentable_with_threading
acts_as_votable
byebug
capistrano (= 3.4.0)
capistrano-bundler (= 1.1.4)
capistrano-rails (= 1.1.3)
capybara
ckeditor
coffee-rails (~> 4.1.0)

37
config/deploy.rb Normal file
View File

@@ -0,0 +1,37 @@
# config valid only for current version of Capistrano
lock '3.4.0'
def deploysecret(key)
@deploy_secrets_yml ||= YAML.load_file('config/deploy-secrets.yml')[fetch(:stage).to_s]
@deploy_secrets_yml[key.to_s]
end
set :rails_env, fetch(:stage)
set :application, 'participacion'
set :repo_url, 'git@github.com:AyuntamientoMadrid/participacion.git'
set :scm, :git
set :revision, `git rev-parse --short #{fetch(:branch)}`.strip
set :log_level, :info
set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{log tmp public/system public/assets}
set :keep_releases, 5
set :local_user, ENV['USER']
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end

View File

@@ -0,0 +1,5 @@
set :deploy_to, deploysecret(:deploy_to)
set :branch, :production
set :ssh_options, port: deploysecret(:ssh_port)
server deploysecret(:server), user: deploysecret(:user), roles: %w(web app db importer)

View File

@@ -0,0 +1,5 @@
set :deploy_to, deploysecret(:deploy_to)
set :branch, :production
set :ssh_options, port: deploysecret(:ssh_port)
server deploysecret(:server), user: deploysecret(:user), roles: %w(web app db importer)

5
config/deploy/staging.rb Normal file
View File

@@ -0,0 +1,5 @@
set :deploy_to, deploysecret(:deploy_to)
set :branch, :master
set :ssh_options, port: deploysecret(:ssh_port)
server deploysecret(:server), user: deploysecret(:user), roles: %w(web app db importer)