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 bcb77c9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 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
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ group :development, :test do
gem 'capistrano-cul', require: false
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 'capistrano-resque', '= 0.2.1', require: false

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

Expand Down
16 changes: 6 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,10 @@ GEM
capistrano-rails (1.6.2)
capistrano (~> 3.1)
capistrano-bundler (>= 1.1, < 3)
capistrano-resque (0.2.3)
capistrano-resque (0.2.1)
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 @@ -664,8 +661,7 @@ DEPENDENCIES
capistrano-cul
capistrano-passenger (~> 0.2)
capistrano-rails (~> 1.4)
capistrano-resque (~> 0.2.2)
capistrano-rvm (~> 0.1)
capistrano-resque (= 0.2.1)
capybara (~> 3.39)
cul-ldap
cul_omniauth (>= 0.7.0)
Expand Down
25 changes: 22 additions & 3 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,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 +39,28 @@
'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("env 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 bcb77c9

Please sign in to comment.