From 5ec4e11c36e56d3d2b0bea88a28acd6a5786b053 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Thu, 14 Sep 2023 13:58:38 -0700 Subject: [PATCH] Add capistrano --- Capfile | 16 ++++++++++++ Gemfile | 8 ++++++ Gemfile.lock | 24 ++++++++++++++++++ config/allsearch.yml | 18 +++++++++++++ config/deploy.rb | 15 +++++++++++ config/deploy/production.rb | 5 ++++ config/deploy/staging.rb | 5 ++++ config/environments/staging.rb | 46 ++++++++++++++++++++++++++++++++++ 8 files changed, 137 insertions(+) create mode 100644 Capfile create mode 100644 config/deploy.rb create mode 100644 config/deploy/production.rb create mode 100644 config/deploy/staging.rb create mode 100644 config/environments/staging.rb diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..edc6e4f --- /dev/null +++ b/Capfile @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Load DSL and set up stages +require 'capistrano/setup' + +# Include default deployment tasks +require 'capistrano/deploy' + +require 'capistrano/scm/git' +install_plugin Capistrano::SCM::Git + +require 'capistrano/bundler' +require 'capistrano/passenger' + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index 713d157..481fef9 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,14 @@ gem 'railties' # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +group :development do + gem 'bcrypt_pbkdf' + gem 'capistrano', require: false + gem 'capistrano-bundler' + gem 'capistrano-passenger' + gem 'ed25519' +end + group :development, :test do gem 'pry-byebug' gem 'reek' diff --git a/Gemfile.lock b/Gemfile.lock index 83b0d44..414dd08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,12 +26,24 @@ GEM tzinfo (~> 2.0) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) + airbrussh (1.4.2) + sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) base64 (0.1.1) + bcrypt_pbkdf (1.1.0) bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) byebug (11.1.3) + capistrano (3.17.3) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-bundler (2.1.0) + capistrano (~> 3.1) + capistrano-passenger (0.2.1) + capistrano (~> 3.0) coderay (1.1.3) concurrent-ruby (1.2.2) crack (0.4.5) @@ -45,6 +57,7 @@ GEM debase-ruby_core_source (3.2.1) diff-lcs (1.5.0) dogstatsd-ruby (5.6.1) + ed25519 (1.3.0) erubi (1.12.0) ffi (1.15.5) hashdiff (1.0.1) @@ -67,6 +80,9 @@ GEM method_source (1.0.0) minitest (5.19.0) msgpack (1.7.2) + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-ssh (7.2.0) nio4r (2.5.9) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) @@ -160,6 +176,9 @@ GEM rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) + sshkit (1.21.5) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) thor (1.2.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -181,9 +200,14 @@ DEPENDENCIES activemodel activerecord activesupport + bcrypt_pbkdf bootsnap + capistrano + capistrano-bundler + capistrano-passenger ddtrace dogstatsd-ruby + ed25519 pg pry-byebug puma (~> 5.0) diff --git a/config/allsearch.yml b/config/allsearch.yml index 2f0e97c..19dfa32 100644 --- a/config/allsearch.yml +++ b/config/allsearch.yml @@ -56,6 +56,24 @@ development: staging: <<: *default + catalog: + solr: + host: "lib-solr8-staging.princeton.edu" + port: 8983 + collection: "catalog-alma-staging" + ssl: true + dpul: + solr: + host: "lib-solr8-staging.princeton.edu" + port: 8983 + collection: "dpul-staging" + ssl: true + findingaids: + solr: + host: "lib-solr8-staging.princeton.edu" + port: 8983 + collection: "pulfalight-staging" + ssl: true test: <<: *default diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..a81f130 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +set :repo_url, 'https://github.com/pulibrary/allsearch_rails_api.git' +set :application, 'allsearch_rails_api' + +set :branch, ENV['BRANCH'] || 'main' + +set :deploy_to, -> { "/opt/#{fetch(:application)}" } +set :repo_path, -> { "/opt/#{fetch(:application)}/repo" } + +set :log_level, :debug + +set :ssh_options, { forward_agent: true } + +set :passenger_restart_with_touch, true diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..a44434b --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +set :stage, :production +set :rails_env, 'production' +server 'allsearch-api-prod1', user: 'deploy' diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 0000000..976b9e6 --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +set :stage, :staging +set :rails_env, 'staging' +server 'allsearch-api-staging1', user: 'deploy' diff --git a/config/environments/staging.rb b/config/environments/staging.rb new file mode 100644 index 0000000..6ac124b --- /dev/null +++ b/config/environments/staging.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info + + # Prepend all log lines with the following tags. + config.log_tags = [:request_id] + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = Logger::Formatter.new + + if ENV['RAILS_LOG_TO_STDOUT'].present? + logger = ActiveSupport::Logger.new($stdout) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end +end