Add capistrano deployment goodies

This commit is contained in:
Tom Naessens 2015-09-08 14:14:24 +02:00
parent c38f363dd6
commit 60c92503c7
8 changed files with 122 additions and 0 deletions

1
.ruby-version Normal file
View file

@ -0,0 +1 @@
2.2.3

11
Capfile Normal file
View file

@ -0,0 +1,11 @@
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/rbenv'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

View file

@ -56,5 +56,11 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
# Deployment
gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv'
gem 'capistrano-passenger'
end

View file

@ -46,6 +46,21 @@ GEM
builder (3.2.2)
byebug (6.0.2)
cancancan (1.12.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-passenger (0.1.1)
capistrano (~> 3.0)
capistrano-rails (1.1.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rbenv (2.0.3)
capistrano (~> 3.1)
sshkit (~> 1.3)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
@ -53,6 +68,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
colorize (0.7.7)
debug_inspector (0.0.2)
devise (3.5.2)
bcrypt (~> 3.0)
@ -96,6 +112,9 @@ GEM
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (1.0.0)
@ -177,6 +196,10 @@ GEM
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
sshkit (1.7.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
@ -202,6 +225,10 @@ DEPENDENCIES
annotate
byebug
cancancan
capistrano (~> 3.1)
capistrano-passenger
capistrano-rails (~> 1.1)
capistrano-rbenv
coffee-rails (~> 4.1.0)
devise
factory_girl_rails

51
config/deploy.rb Normal file
View file

@ -0,0 +1,51 @@
# config valid only for Capistrano 3.1
# lock '3.1.0'
set :application, 'Tab'
set :repo_url, 'git@github.com:ZeusWPI/Tab.git'
set :branch, 'master'
set :deploy_to, '/home/tab/production'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/secrets.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :passenger do
desc "Restart Application"
task :restart do
on roles(:app) do
with rails_env: fetch(:rails_env) do
execute "touch #{current_path}/tmp/restart.txt"
end
end
end
end
after :deploy, "passenger:restart"

View file

@ -0,0 +1,9 @@
server 'zeus.ugent.be', user: 'tab', roles: %w{web app db}, ssh_options: {
forward_agent: true,
auth_methods: ['publickey'],
port: 2222
}
set :rails_env, 'production'
set :rbenv_type, :system
set :rbenv_ruby, File.read('.ruby-version').strip

9
config/deploy/staging.rb Normal file
View file

@ -0,0 +1,9 @@
server 'king.ugent.be', user: 'tap', roles: %w{web app db}, ssh_options: {
forward_agent: true,
auth_methods: ['publickey'],
port: 2222
}
set :rails_env, 'production'
set :rbenv_type, :system
set :rbenv_ruby, File.read('.ruby-version').strip

View file

@ -0,0 +1,8 @@
namespace :logs do
desc "tail rails logs"
task :tail do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
end