Skip to content

Commit

Permalink
specify node and rvm versions via custom alias
Browse files Browse the repository at this point in the history
  • Loading branch information
JackBlackLight committed Nov 16, 2023
1 parent ff8ce5f commit 2ca5227
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
2 changes: 0 additions & 2 deletions Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ install_plugin Capistrano::SCM::Git
#
# 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
Expand All @@ -21,7 +20,6 @@ install_plugin Capistrano::SCM::Git
#

require 'capistrano/rails'
require 'capistrano/rvm'
require 'capistrano/passenger'

require 'capistrano/cul'
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ group :development, :test do
gem 'capistrano-passenger', '~> 0.2', require: false
gem 'capistrano-rails', '~> 1.4', require: false
gem 'capistrano-resque', '~> 0.2.2', require: false
gem 'capistrano-rvm', '~> 0.1', require: false

gem 'rubocul', '~> 4.0', require: false

Expand Down
12 changes: 4 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ GEM
capistrano
resque
resque-scheduler
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capybara (3.39.2)
addressable
matrix
Expand Down Expand Up @@ -241,7 +238,7 @@ GEM
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
fugit (1.5.3)
fugit (1.9.0)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
gaffe (1.2.0)
Expand Down Expand Up @@ -463,11 +460,11 @@ GEM
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (4.5.0)
resque-scheduler (4.10.0)
mono_logger (~> 1.0)
redis (>= 3.3)
resque (>= 1.27)
rufus-scheduler (~> 3.2, < 3.7)
rufus-scheduler (~> 3.2, != 3.3)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
Expand Down Expand Up @@ -547,7 +544,7 @@ GEM
nokogiri
rest-client
rubyzip (1.3.0)
rufus-scheduler (3.6.0)
rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6)
selenium-webdriver (4.11.0)
rexml (~> 3.2, >= 3.2.5)
Expand Down Expand Up @@ -665,7 +662,6 @@ DEPENDENCIES
capistrano-passenger (~> 0.2)
capistrano-rails (~> 1.4)
capistrano-resque (~> 0.2.2)
capistrano-rvm (~> 0.1)
capybara (~> 3.39)
cul-ldap
cul_omniauth (>= 0.7.0)
Expand Down
30 changes: 26 additions & 4 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
# used to run rake db:migrate, etc
# Default value for :rails_env is fetch(:stage)
set :rails_env, fetch(:deploy_name)
# use the rvm wrapper
# use the rvm and nvm wrappers
set :rvm_custom_path, '~/.rvm-alma8'
set :nvm_custom_path, '~/.nvm-alma8'
set :rvm_ruby_version, fetch(:deploy_name)

set :repo_url, "[email protected]:cul/ac-academiccommons.git"
Expand All @@ -21,9 +22,6 @@
# Default value for :format is :airbrussh
# set :format, :airbrussh

# Default value for :log_level is :debug
set :log_level, :info

# Default value for linked_dirs is []
set :linked_dirs,
fetch(:linked_dirs, []).push('log','tmp/pids', 'storage', 'public/feature-logos', 'node_modules', 'public/packs')
Expand All @@ -42,6 +40,30 @@
'public/robots.txt',
)

# Default value for :log_level is :debug
set :log_level, :info

# NVM Setup, for selecting the correct node version
# NOTE: This NVM configuration MUST be configured before the RVM setup steps because:
# This works:
# nvm exec 16 ~/.rvm-alma8/bin/rvm example_app_dev do node --version
# But this does not work:
# ~/.rvm-alma8/bin/rvm example_app_dev do nvm exec 16 node --version
set :nvm_node_version, fetch(:deploy_name) # This NVM alias must exist on the server
[:rake, :node, :npm, :yarn].each do |command_to_prefix|
# SSHKit.config.command_map.prefix[command_to_prefix].push("nvm exec #{fetch(:nvm_node_version)}")
SSHKit.config.command_map.prefix[command_to_prefix].push("#{fetch(:nvm_custom_path,
'~/.nvm')}/nvm-exec #{fetch(:nvm_node_version)}")
end

# RVM Setup, for selecting the correct ruby version (instead of capistrano-rvm gem)
set :rvm_ruby_version, fetch(:deploy_name) # This RVM alias must exist on the server
[:rake, :gem, :bundle, :ruby].each do |command_to_prefix|
SSHKit.config.command_map.prefix[command_to_prefix].push(
"#{fetch(:rvm_custom_path, '~/.rvm')}/bin/rvm #{fetch(:rvm_ruby_version)} do"
)
end

set :ssh_options, { forward_agent: true }

# Namespace crontab based on app environment.
Expand Down

0 comments on commit 2ca5227

Please sign in to comment.