From eb32abb7e25e6cf365a331882b8bf438fce17567 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sun, 31 Aug 2014 17:18:10 +0300 Subject: [PATCH] Initial deployment setup --- Capfile | 28 ++++++++++++++++++++++ Gemfile | 4 ++++ Gemfile.lock | 24 +++++++++++++++++++ config/deploy.rb | 48 +++++++++++++++++++++++++++++++++++++ config/deploy/production.rb | 41 +++++++++++++++++++++++++++++++ 5 files changed, 145 insertions(+) create mode 100644 Capfile create mode 100644 config/deploy.rb create mode 100644 config/deploy/production.rb diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..cb0d4a5 --- /dev/null +++ b/Capfile @@ -0,0 +1,28 @@ +# Load DSL and Setup Up Stages +require 'capistrano/setup' + +# Includes default deployment tasks +require 'capistrano/deploy' + +# Includes tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# +# require 'capistrano/rvm' +# require 'capistrano/rbenv' +# require 'capistrano/chruby' +# require 'capistrano/bundler' +# require 'capistrano/rails/assets' +# require 'capistrano/rails/migrations' + +require 'capistrano/rails' +require 'capistrano/rvm' + +# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index 9e8c2c8..a3edbaf 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,10 @@ gem 'phony_rails' # Picture uploads gem 'carrierwave' +gem 'capistrano' +gem 'capistrano-rails' +gem 'capistrano-rvm' + group :development do gem 'spring' gem 'spring-commands-rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 06dfa18..8efbcca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,6 +30,19 @@ GEM arel (5.0.1.20140414130214) bcrypt (3.1.7) builder (3.2.2) + capistrano (3.2.1) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + capistrano-bundler (1.1.2) + capistrano (~> 3.0) + sshkit (~> 1.2) + capistrano-rails (1.1.1) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-rvm (0.1.1) + capistrano (~> 3.0) + sshkit (~> 1.2) capybara (2.4.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -52,6 +65,7 @@ GEM coffee-script-source execjs coffee-script-source (1.8.0) + colorize (0.7.3) countries (0.9.3) currencies (~> 0.4.2) currencies (0.4.2) @@ -103,6 +117,9 @@ GEM mini_portile (0.6.0) minitest (5.4.1) multi_json (1.10.1) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.1) nokogiri (1.6.3.1) mini_portile (= 0.6.0) orm_adapter (0.5.0) @@ -200,6 +217,10 @@ GEM activesupport (>= 3.0) sprockets (~> 2.8) sqlite3 (1.3.9) + sshkit (1.5.1) + colorize + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) temple (0.6.8) therubyracer (0.12.1) libv8 (~> 3.16.14.0) @@ -225,6 +246,9 @@ PLATFORMS ruby DEPENDENCIES + capistrano + capistrano-rails + capistrano-rvm capybara carrierwave coffee-rails diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..dd3e111 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,48 @@ +# config valid only for Capistrano 3.1 +lock '3.2.1' + +set :application, 'clarion' +set :repo_url, 'https://github.com/ignisf/clarion.git' + +# Default branch is :master +# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call + +# Default deploy_to directory is /var/www/my_app +set :deploy_to, '/home/barf/clarion' + +# 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/puma.rb 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 :deploy do + + desc 'Restart application' + task :restart do + on roles(:app), in: :sequence, wait: 5 do + # Your restart mechanism here, for example: + execute :touch, release_path.join('tmp/restart.txt') + end + end + + after :publishing, :restart +end diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..74ee85a --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,41 @@ +# Simple Role Syntax +# ================== +# Supports bulk-adding hosts to roles, the primary server in each group +# is considered to be the first unless any hosts have the primary +# property set. Don't declare `role :all`, it's a meta role. + + +# Extended Server Syntax +# ====================== +# This can be used to drop a more detailed server definition into the +# server list. The second argument is a, or duck-types, Hash and is +# used to set extended properties on the server. + +server 'marla.ludost.net', user: 'barf', roles: %w{web db app} + + +# Custom SSH Options +# ================== +# You may pass any option but keep in mind that net/ssh understands a +# limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start). +# +# Global options +# -------------- +# set :ssh_options, { +# keys: %w(/home/rlisowski/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(password) +# } +# +# And/or per server (overrides global) +# ------------------------------------ +# server 'example.com', +# user: 'user_name', +# roles: %w{web app}, +# ssh_options: { +# user: 'user_name', # overrides user setting above +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(publickey password) +# # password: 'please use keys' +# }