-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from cul/capistrano-updates
deployment config updates (and now using capistrano-cul)
- Loading branch information
Showing
4 changed files
with
103 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
# Load DSL and set up stages | ||
require "capistrano/setup" | ||
require 'capistrano/setup' | ||
|
||
# Include default deployment tasks | ||
require "capistrano/deploy" | ||
require 'capistrano/deploy' | ||
|
||
# Load the SCM plugin appropriate to your project: | ||
# | ||
# require "capistrano/scm/hg" | ||
# install_plugin Capistrano::SCM::Hg | ||
# or | ||
# require "capistrano/scm/svn" | ||
# install_plugin Capistrano::SCM::Svn | ||
# or | ||
require "capistrano/scm/git" | ||
# Git SCM plugin | ||
require 'capistrano/scm/git' | ||
install_plugin Capistrano::SCM::Git | ||
|
||
# Include 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 | ||
# https://github.com/capistrano/passenger | ||
# | ||
# require "capistrano/rvm" | ||
# require "capistrano/rbenv" | ||
# require "capistrano/chruby" | ||
# require "capistrano/bundler" | ||
# require "capistrano/rails/assets" | ||
# require "capistrano/rails/migrations" | ||
# require "capistrano/passenger" | ||
# additional modules | ||
require 'capistrano/rails' | ||
require 'capistrano/rvm' | ||
require 'capistrano/passenger' | ||
require 'capistrano/cul' | ||
|
||
# Load custom tasks from `lib/capistrano/tasks` if you have any defined | ||
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } | ||
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,87 @@ | ||
# config valid only for current version of Capistrano | ||
lock "~> 3.17.3" | ||
# frozen_string_literal: true | ||
|
||
set :department, 'ldpd' | ||
set :instance, fetch(:department) | ||
# config valid for current version and patch releases of Capistrano | ||
lock '~> 3.18.0' | ||
|
||
# Until we retire all old CentOS VMs, we need to set the rvm_custom_path because rvm is installed | ||
# in a non-standard location for our AlmaLinux VMs. This is because our service accounts need to | ||
# maintain two rvm installations for two different Linux OS versions. | ||
set :rvm_custom_path, '~/.rvm-alma8' | ||
|
||
set :remote_user, 'renserv' | ||
set :application, 'hours' | ||
set :repo_name, "ldpd-hours" | ||
set :repo_url, "[email protected]:cul/ldpd-hours.git" | ||
set :deploy_name, "#{fetch(:application)}_#{fetch(:stage)}" | ||
# 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 | ||
set :rvm_custom_path, '~/.rvm-alma8' | ||
set :rvm_ruby_version, fetch(:deploy_name) | ||
|
||
set :repo_url, "[email protected]:cul/#{fetch(:repo_name)}.git" | ||
|
||
set :remote_user, "renserv" | ||
|
||
# Default deploy_to directory is /var/www/:application | ||
set :deploy_to, "/opt/passenger/#{fetch(:deploy_name)}" | ||
# Default deploy_to directory is /var/www/my_app_name | ||
set :deploy_to, "/opt/passenger/#{fetch(:deploy_name)}" | ||
|
||
# Default value for :log_level is :debug | ||
set :log_level, :info | ||
# Default value for :linked_files is [] | ||
append :linked_files, | ||
'config/database.yml', | ||
'config/secrets.yml', | ||
'config/wifi_density.yml' | ||
|
||
# Default value for linked_dirs is [] | ||
set :linked_dirs, fetch(:linked_dirs, []).push('log') | ||
append :linked_dirs, 'log', 'tmp/pids', 'node_modules' | ||
|
||
set :passenger_restart_with_touch, true | ||
|
||
# Default value for keep_releases is 5 | ||
set :keep_releases, 3 | ||
|
||
set :passenger_restart_with_touch, true | ||
# Set default log level (which can be overridden by other environments) | ||
set :log_level, :info | ||
|
||
set :linked_files, fetch(:linked_files, []).push( | ||
"config/database.yml", | ||
"config/secrets.yml", | ||
"config/wifi_density.yml" | ||
) | ||
|
||
before "deploy:assets:precompile", "deploy:yarn_install" | ||
|
||
namespace :deploy do | ||
desc "Report the environment" | ||
task :report do | ||
run_locally do | ||
puts "cap called with stage = \"#{fetch(:stage,'none')}\"" | ||
puts "cap would deploy to = \"#{fetch(:deploy_to,'none')}\"" | ||
puts "cap would install from #{fetch(:repo_url)}" | ||
puts "cap would install in Rails env #{fetch(:rails_env)}" | ||
end | ||
end | ||
# 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 | ||
|
||
desc "Add tag based on current version from VERSION file" | ||
task :auto_tag do | ||
current_version = "v#{IO.read("VERSION").strip}" | ||
# Default value for default_env is {} | ||
set :default_env, NODE_ENV: 'production' | ||
|
||
ask(:tag, current_version) | ||
tag = fetch(:tag) | ||
# Default branch is :master | ||
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp | ||
|
||
system("git tag -a #{tag} -m 'auto-tagged' && git push origin --tags") | ||
end | ||
# Default value for :scm is :git | ||
# set :scm, :git | ||
|
||
# Default value for :format is :airbrussh | ||
# set :format, :airbrussh | ||
|
||
# You can configure the Airbrussh format using :format_options. | ||
# These are the defaults. | ||
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto | ||
|
||
# Default value for :pty is false | ||
# set :pty, true | ||
|
||
# Default value for local_user is ENV['USER'] | ||
# set :local_user, -> { `git config user.name`.chomp } | ||
|
||
# Uncomment the following to require manually verifying the host key before first deploy. | ||
# set :ssh_options, verify_host_key: :secure | ||
|
||
before 'deploy:assets:precompile', 'hours:yarn_install' | ||
|
||
namespace :hours do | ||
desc "Run rake yarn install" | ||
task :yarn_install do | ||
on roles(:web) do | ||
|