From 46035f7deef27cffd48bf22dae2d9b39d6e67078 Mon Sep 17 00:00:00 2001 From: JackBlackLight Date: Mon, 13 Nov 2023 11:45:28 -0600 Subject: [PATCH] specify node and rvm versions via custom alias --- Capfile | 2 -- Gemfile | 3 +-- Gemfile.lock | 16 ++++++---------- config/deploy.rb | 25 ++++++++++++++++++++++--- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Capfile b/Capfile index 9c8794c85..2f2f29322 100644 --- a/Capfile +++ b/Capfile @@ -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 @@ -21,7 +20,6 @@ install_plugin Capistrano::SCM::Git # require 'capistrano/rails' -require 'capistrano/rvm' require 'capistrano/passenger' require 'capistrano/cul' diff --git a/Gemfile b/Gemfile index 72cfbf467..45c38b562 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index ecbea91ab..e7705238e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/config/deploy.rb b/config/deploy.rb index 0cfa90754..c24da9bdb 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -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') @@ -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("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.