Skip to content

Commit

Permalink
capistrano v3.8 + appliance deployment update
Browse files Browse the repository at this point in the history
  • Loading branch information
alexskr committed Jul 20, 2017
1 parent 5651dce commit 36fea81
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ require 'capistrano/deploy'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
#require 'capistrano/rails/assets'
#require 'capistrano/rails/migrations'
require 'capistrano/rails'
require 'capistrano/locally'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ end

group :development do
#Capistrano
gem 'capistrano', '~> 3.4.1', require: false
gem 'capistrano', '~> 3.8.2', require: false
#capistrano-locally required for deployments to localhost
gem 'capistrano-locally', require: false
# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0', require: false
# integrate bundler with capistrano
Expand Down
16 changes: 11 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ncbo/ontologies_api_ruby_client.git
revision: 3ecd094615b84253cac0d81ccdc757b9d6743637
revision: f2a5b3ddef23b642ed8430517612c8f9d8ada91a
branch: staging
specs:
ontologies_api_client (0.0.6)
Expand Down Expand Up @@ -59,20 +59,25 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
airbrussh (1.3.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (6.0.4)
autoprefixer-rails (7.1.2.3)
execjs
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3)
capistrano (3.4.1)
capistrano (3.8.2)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
sshkit (>= 1.9.0)
capistrano-bundler (1.2.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-locally (0.2.4)
capistrano (~> 3.0)
capistrano-passenger (0.2.0)
capistrano (~> 3.0)
capistrano-rails (1.1.8)
Expand Down Expand Up @@ -243,8 +248,9 @@ PLATFORMS

DEPENDENCIES
bootstrap-sass (~> 3.3.7)
capistrano (~> 3.4.1)
capistrano (~> 3.8.2)
capistrano-bundler
capistrano-locally
capistrano-passenger
capistrano-rails (~> 1.1.0)
chart-js-rails
Expand Down Expand Up @@ -283,4 +289,4 @@ DEPENDENCIES
will_paginate (~> 3.0)

BUNDLED WITH
1.13.7
1.15.1
10 changes: 9 additions & 1 deletion config/database.yml.production → config/database.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ production:
database: bioportal_ui
username: bp_user
password: bp_user!!!
host: localhost
host: localhost

appliance:
adapter: mysql
socket: /var/lib/mysql/mysql.sock
database: bioportal_ui_appliance
username: bp_user
password: bp_user!!!
host: localhost
32 changes: 21 additions & 11 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# config valid only for Capistrano 3.1
lock '3.4.1'
#lock '3.7.1'

set :application, 'bioportal_web_ui'

set :repo_url, "git@github.com:ncbo/#{fetch(:application)}.git"
set :repo_url, "https://github.com/ncbo/#{fetch(:application)}.git"

#set :deploy_via, :remote_cache
set :deploy_via, :remote_cache

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
Expand All @@ -26,7 +25,7 @@
# set :pty, true

# Default value for :linked_files is []
#set :linked_files, %w{config/bioportal_config.rb config/database.yml public/robots.txt config/newrelic.yml}
#set :linked_files, %w{config/bioportal_config.rb config/database.yml public/robots.txt}

# Default value for linked_dirs is []
#set :linked_dirs, %w{bin log tmp/pids tmp/cache public/system public/assets config/locales}
Expand All @@ -49,18 +48,30 @@

namespace :deploy do

desc 'display remote system env vars'
task :show_remote_env do
on roles(:all) do
remote_env = capture("env")
puts remote_env
end
end

desc 'Incorporate the bioportal_conf private repository content'
#Get cofiguration from repo if PRIVATE_CONFIG_REPO is set
#(should be set to NCBO private config repo)
#Get cofiguration from repo if PRIVATE_CONFIG_REPO env var is set
#or get config from local directory if LOCAL_CONFIG_PATH env var is set
task :get_config do
if defined?(PRIVATE_CONFIG_REPO)
TMP_CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}"
on roles(:web) do
TMP_CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}"
execute "git clone -q #{PRIVATE_CONFIG_REPO} #{TMP_CONFIG_PATH}"
execute "rsync -av #{TMP_CONFIG_PATH}/#{fetch(:application)}/ #{release_path}/"
execute "rm -rf #{TMP_CONFIG_PATH}"
end
end
end
elsif defined?(LOCAL_CONFIG_PATH)
on roles(:web) do
execute "rsync -av #{LOCAL_CONFIG_PATH}/#{fetch(:application)}/ #{release_path}/"
end
end
end

desc 'Restart application'
Expand All @@ -71,7 +82,6 @@
end
end

#before :started, :get_config
after :updating, :get_config
after :publishing, :restart

Expand Down
48 changes: 48 additions & 0 deletions config/deploy/appliance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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
#role :app, %w{deploy@example.com}
#role :web, %w{deploy@example.com}
#role :db, %w{deploy@example.com}

# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.
server 'localhost', roles: %w{web db}

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# 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'
# }
# setting per server overrides global ssh_options
#
NCBO_BRANCH = ENV.include?('NCBO_BRANCH') ? ENV['NCBO_BRANCH'] : 'master'
set :branch, "#{NCBO_BRANCH}"

#private git repo for configuraiton
#PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'git@github.com:your_org/private-config-repo.git'

#location of configuration files
LOCAL_CONFIG_PATH = ENV.include?('LOCAL_CONFIG_PATH') ? ENV['LOCAL_CONFIG_PATH'] : '~/virtual_appliance/appliance_config'

0 comments on commit 36fea81

Please sign in to comment.