diff --git a/.circleci/config.yml b/.circleci/config.yml index fb2de2d7..45f9c970 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,6 +34,7 @@ jobs: - run: sudo apt-get -y update - run: sudo apt-get install -y postgresql-client || true - run: gem install bundler -v '~> 2.0' + - run: bundle config set --local without production - run: name: Install dependencies command: bundle install --path=vendor/bundle --jobs 4 --retry 3 diff --git a/Gemfile b/Gemfile index d44e885b..f6c36b11 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,6 @@ gem 'capistrano-rails' gem 'capistrano-rails-console', require: false gem 'capybara' gem 'change_the_subject', '~> 0.3.2' -gem 'ddtrace', '~> 0.54.2' gem 'devise' gem 'ed25519' gem 'faraday', '~> 1.0' @@ -24,6 +23,7 @@ gem 'friendly_id' gem 'gyoku', '~> 1.0' gem 'high_voltage', '~> 3.0' gem 'honeybadger' +gem 'human_languages', '~> 0.7' gem 'jbuilder' gem 'jquery-rails' gem 'jquery-tablesorter', '~> 1.21' @@ -44,6 +44,8 @@ gem 'net-sftp' gem 'net-smtp', require: false gem 'oj' gem 'omniauth-cas' +gem 'omniauth-rails_csrf_protection' +gem 'open3' gem 'orangetheses', github: 'pulibrary/orangetheses', ref: '4ac8dc2bd04b10db764fc37df3261531c9937061' gem 'pg' gem "rack", ">= 2.0.6" @@ -68,6 +70,10 @@ gem 'turbolinks' gem 'whenever', "~> 0.10" gem 'yard' +group :production do + gem "ddtrace", '~> 0.54.2' +end + group :development, :test do # bundler and rake come in from the voyager_helpers gemspec gem 'coveralls_reborn' @@ -89,9 +95,3 @@ group :test do gem 'axe-core-api' gem 'axe-core-rspec' end - -gem "omniauth-rails_csrf_protection" - -gem "human_languages", "~> 0.7" - -gem "open3" diff --git a/config/alma.yml b/config/alma.yml index 429e31b8..433769fc 100644 --- a/config/alma.yml +++ b/config/alma.yml @@ -31,3 +31,9 @@ test: production: <<: *default + +qa: + <<: *default + +staging: + <<: *default diff --git a/config/application.rb b/config/application.rb index c6f56a52..94aefb60 100644 --- a/config/application.rb +++ b/config/application.rb @@ -3,9 +3,9 @@ require 'rails/all' require_relative 'lando_env' if Rails.env.development? || Rails.env.test? -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) +# Require the gems listed in Gemfile, but only the default ones +# and those for the environment rails is running in +Bundler.require(:default, Rails.env) module MarcLiberation class Application < Rails::Application diff --git a/config/authz.yml b/config/authz.yml index 16d6d8c8..dc4a2e6c 100644 --- a/config/authz.yml +++ b/config/authz.yml @@ -10,3 +10,9 @@ test: production: <<: *default + +qa: + <<: *default + +staging: + <<: *default diff --git a/config/database.yml b/config/database.yml index 0028646c..428c12fe 100644 --- a/config/database.yml +++ b/config/database.yml @@ -27,3 +27,7 @@ production: staging: <<: *default pool: 20 + +qa: + <<: *default + pool: 20 diff --git a/config/deploy/qa.rb b/config/deploy/qa.rb index 11e6ed51..11c736a0 100644 --- a/config/deploy/qa.rb +++ b/config/deploy/qa.rb @@ -7,7 +7,7 @@ set :application, 'bibdata' set :stage, :production -set :rails_env, 'production' +set :rails_env, 'qa' server 'bibdata-qa1.princeton.edu', user: 'deploy', roles: [:web, :app, :db, :hr_cron, :poller] server 'bibdata-qa2.princeton.edu', user: 'deploy', roles: [:web, :app, :db, :hr_cron, :poller] server 'bibdata-worker-qa1.princeton.edu', user: 'deploy', roles: [:db, :worker, :cron, :cron_staging, :poller] diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 5d6d3969..034eb537 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -6,7 +6,7 @@ set :application, 'bibdata' set :stage, :production -set :rails_env, 'production' +set :rails_env, 'staging' server 'bibdata-alma-staging1.princeton.edu', user: 'deploy', roles: [:web, :app, :db, :hr_cron, :poller] server 'bibdata-alma-staging2.princeton.edu', user: 'deploy', roles: [:web, :app, :db, :hr_cron, :poller] server 'bibdata-alma-worker-staging1.princeton.edu', user: 'deploy', roles: [:db, :worker, :cron, :cron_staging, :poller] diff --git a/config/environments/qa.rb b/config/environments/qa.rb new file mode 100644 index 00000000..9df478e9 --- /dev/null +++ b/config/environments/qa.rb @@ -0,0 +1,91 @@ +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 + config.action_controller.perform_caching = true + + view_logger = Logger.new(STDOUT) + view_logger.level = Logger::WARN + config.action_view.logger = view_logger + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_files = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :terser + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + # config.action_mailer.delivery_method = :sendmail + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: 'lib-ponyexpr.princeton.edu' + } + config.action_mailer.default_options = { + from: 'no-reply@princeton.edu' + } + # 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 + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + config.action_mailer.default_url_options = { host: ENV["APPLICATION_URL"] || "bibdata-qa.princeton.edu", protocol: "https" } +end diff --git a/config/environments/staging.rb b/config/environments/staging.rb new file mode 100644 index 00000000..fa97425d --- /dev/null +++ b/config/environments/staging.rb @@ -0,0 +1,91 @@ +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 + config.action_controller.perform_caching = true + + view_logger = Logger.new(STDOUT) + view_logger.level = Logger::WARN + config.action_view.logger = view_logger + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_files = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :terser + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + # config.action_mailer.delivery_method = :sendmail + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: 'lib-ponyexpr.princeton.edu' + } + config.action_mailer.default_options = { + from: 'no-reply@princeton.edu' + } + # 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 + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + config.action_mailer.default_url_options = { host: ENV["APPLICATION_URL"] || "bibdata-staging.princeton.edu", protocol: "https" } +end diff --git a/config/initializers/datadog.rb b/config/initializers/datadog.rb index f7c338fa..58e5903e 100644 --- a/config/initializers/datadog.rb +++ b/config/initializers/datadog.rb @@ -1,21 +1,22 @@ # frozen_string_literal: true - -Datadog.configure do |c| - c.tracer(enabled: false) unless Rails.env.production? - c.env = 'production' - c.service = 'bibdata' - # Rails - c.use :rails - - # Redis - c.use :redis - - # Net::HTTP - c.use :http - - # Sidekiq - c.use :sidekiq - - # Faraday - c.use :faraday +if Rails.env.production? + Datadog.configure do |c| + c.tracer(enabled: false) unless Rails.env.production? + c.env = Rails.env + c.service = 'bibdata' + # Rails + c.use :rails + + # Redis + c.use :redis + + # Net::HTTP + c.use :http + + # Sidekiq + c.use :sidekiq + + # Faraday + c.use :faraday + end end diff --git a/config/ip_allowlist.yml b/config/ip_allowlist.yml index cbf9b6c4..63db2f00 100644 --- a/config/ip_allowlist.yml +++ b/config/ip_allowlist.yml @@ -1,8 +1,15 @@ +default: &default + addresses: <%= ENV["BIBDATA_IP_ALLOWLIST"] || "" %> + development: addresses: "127.0.0.1 ::1" test: addresses: "127.0.0.1" +staging: + <<: *default +qa: + <<: *default production: - addresses: <%= ENV["BIBDATA_IP_ALLOWLIST"] || "" %> + <<: *default diff --git a/config/traject.yml b/config/traject.yml index c4717a3e..72fb8fbd 100644 --- a/config/traject.yml +++ b/config/traject.yml @@ -9,3 +9,9 @@ test: production: <<: *default + +staging: + <<: *default + +qa: + <<: *default