Upgrade to Rails 6.0 and apply new framework defaults
This commit is contained in:
@ -10,8 +10,8 @@ require 'telegraf/rails'
|
||||
|
||||
module CodeOcean
|
||||
class Application < Rails::Application
|
||||
# Initialize configuration defaults
|
||||
config.load_defaults 5.2
|
||||
# Initialize configuration defaults for originally generated Rails version.
|
||||
config.load_defaults 6.0
|
||||
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration can go into files in config/initializers
|
||||
@ -27,9 +27,21 @@ module CodeOcean
|
||||
# config.i18n.default_locale = :de
|
||||
config.i18n.available_locales = [:de, :en]
|
||||
|
||||
config.autoload_paths << Rails.root.join('lib')
|
||||
config.eager_load_paths << Rails.root.join('lib')
|
||||
config.assets.precompile += %w( markdown-buttons.png )
|
||||
# Add inflection for Zeitwerk
|
||||
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
inflect.acronym 'IO'
|
||||
end
|
||||
|
||||
extra_paths = %W[
|
||||
#{config.root}/lib
|
||||
]
|
||||
|
||||
# Add generators, they don't have a module structure that matches their directory structure.
|
||||
extra_paths << "#{config.root}/lib/generators"
|
||||
|
||||
config.add_autoload_paths_to_load_path = false
|
||||
config.autoload_paths += extra_paths
|
||||
config.eager_load_paths += extra_paths
|
||||
|
||||
config.action_cable.mount_path = '/cable'
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
development:
|
||||
adapter: postgresql
|
||||
adapter: async
|
||||
|
||||
test:
|
||||
adapter: postgresql
|
||||
adapter: test
|
||||
|
||||
staging:
|
||||
adapter: postgresql
|
||||
|
@ -1,8 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.configure do
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = true
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
config.web_console.whitelisted_ips = '192.168.0.0/16'
|
||||
@ -20,8 +18,9 @@ Rails.application.configure do
|
||||
|
||||
# Enable/disable caching. By default caching is disabled.
|
||||
# Run rails dev:cache to toggle caching.
|
||||
if Rails.root.join('tmp/caching-dev.txt').exist?
|
||||
if Rails.root.join('tmp', 'caching-dev.txt').exist?
|
||||
config.action_controller.perform_caching = true
|
||||
config.action_controller.enable_fragment_cache_logging = true
|
||||
|
||||
config.cache_store = :memory_store
|
||||
config.public_file_server.headers = {
|
||||
@ -33,7 +32,7 @@ Rails.application.configure do
|
||||
config.cache_store = :null_store
|
||||
end
|
||||
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options)
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||
config.active_storage.service = :local
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
@ -55,26 +54,22 @@ Rails.application.configure do
|
||||
# number of complex assets.
|
||||
config.assets.debug = true
|
||||
|
||||
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
||||
# yet still be able to expire them through the digest params.
|
||||
config.assets.digest = true
|
||||
|
||||
# Suppress logger output for asset requests.
|
||||
config.assets.quiet = true
|
||||
|
||||
# Raises error for missing translations
|
||||
config.action_view.raise_on_missing_translations = true
|
||||
|
||||
# Adds additional error checking when serving assets at runtime.
|
||||
# Checks for improperly declared sprockets dependencies.
|
||||
# Raises helpful error messages.
|
||||
config.assets.raise_runtime_errors = true
|
||||
|
||||
# Raises error for missing translations
|
||||
config.action_view.raise_on_missing_translations = true
|
||||
|
||||
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']
|
||||
|
||||
# Use an evented file watcher to asynchronously detect changes in source code,
|
||||
# routes, locales, etc. This feature depends on the listen gem and might not
|
||||
# work within a Vagrant environment.
|
||||
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
config.file_watcher = ActiveSupport::FileUpdateChecker
|
||||
# routes, locales, etc. This feature depends on the listen gem.
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
# If the evented file watcher doesn't work (in Vagrant), use another one:
|
||||
# config.file_watcher = ActiveSupport::FileUpdateChecker
|
||||
end
|
||||
|
@ -1,8 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.configure do
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = false
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
@ -27,20 +25,13 @@ Rails.application.configure do
|
||||
# Apache or NGINX already handles this.
|
||||
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
# Compress JavaScript and CSS using a preprocessor.
|
||||
config.assets.js_compressor = Uglifier.new(harmony: true)
|
||||
# config.assets.js_compressor = :uglifier
|
||||
# config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
config.assets.compile = false
|
||||
|
||||
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
||||
# yet still be able to expire them through the digest params.
|
||||
config.assets.digest = true
|
||||
|
||||
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||
# config.action_controller.asset_host = 'http://assets.example.com'
|
||||
|
||||
@ -48,10 +39,10 @@ Rails.application.configure do
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
||||
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options)
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||
config.active_storage.service = :local
|
||||
|
||||
# Mount Action Cable outside main process or domain
|
||||
# Mount Action Cable outside main process or domain.
|
||||
# config.action_cable.mount_path = nil
|
||||
# config.action_cable.url = 'wss://example.com/cable'
|
||||
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
||||
@ -69,9 +60,9 @@ Rails.application.configure do
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment)
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment).
|
||||
# config.active_job.queue_adapter = :resque
|
||||
# config.active_job.queue_name_prefix = "code_ocean_#{Rails.env}"
|
||||
# config.active_job.queue_name_prefix = "code_ocean_production"
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
@ -101,4 +92,25 @@ Rails.application.configure do
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
# Inserts middleware to perform automatic connection switching.
|
||||
# The `database_selector` hash is used to pass options to the DatabaseSelector
|
||||
# middleware. The `delay` is used to determine how long to wait after a write
|
||||
# to send a subsequent read to the primary.
|
||||
#
|
||||
# The `database_resolver` class is used by the middleware to determine which
|
||||
# database is appropriate to use based on the time delay.
|
||||
#
|
||||
# The `database_resolver_context` class is used by the middleware to set
|
||||
# timestamps for the last write to the primary. The resolver uses the context
|
||||
# class timestamps to determine how long to wait before reading from the
|
||||
# replica.
|
||||
#
|
||||
# By default Rails will store a last write timestamp in the session. The
|
||||
# DatabaseSelector middleware is designed as such you can define your own
|
||||
# strategy for connection switching and pass that into the middleware through
|
||||
# these configuration options.
|
||||
# config.active_record.database_selector = { delay: 2.seconds }
|
||||
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
|
||||
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
|
||||
end
|
||||
|
@ -1,13 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
config.cache_classes = false
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
# just for the purpose of running a single test. If you are using a tool that
|
||||
@ -24,6 +25,7 @@ Rails.application.configure do
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
config.cache_store = :memory_store
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
@ -31,7 +33,7 @@ Rails.application.configure do
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Store uploaded files on the local file system in a temporary directory
|
||||
# Store uploaded files on the local file system in a temporary directory.
|
||||
config.active_storage.service = :test
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
@ -47,10 +49,6 @@ Rails.application.configure do
|
||||
# Print deprecation notices to the stderr.
|
||||
config.active_support.deprecation = :stderr
|
||||
|
||||
# Raises error for missing translations
|
||||
# Raises error for missing translations.
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
|
||||
# config.logger = Logger.new($stdout)
|
||||
# Set log level
|
||||
# config.log_level = :DEBUG
|
||||
end
|
||||
|
@ -1,3 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'code_ocean/config'
|
||||
|
||||
CodeOcean::Config.new(:action_mailer).read.each do |key, value|
|
||||
CodeOcean::Application.config.action_mailer.send(:"#{key}=", value.respond_to?(:symbolize_keys) ? value.symbolize_keys : value)
|
||||
end
|
||||
|
@ -1,20 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Rails.application.config.tap do |config|
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
Rails.application.config.assets.version = '1.0'
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
config.assets.version = '1.0'
|
||||
# Add additional assets to the asset load path.
|
||||
# Rails.application.config.assets.paths << Emoji.images_path
|
||||
# Add Yarn node_modules folder to the asset load path.
|
||||
Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
||||
|
||||
# Add additional assets to the asset load path.
|
||||
# config.assets.paths << Emoji.images_path
|
||||
# Add Yarn node_modules folder to the asset load path.
|
||||
config.assets.paths << Rails.root.join('node_modules')
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in the app/assets
|
||||
# folder are already added.
|
||||
# config.assets.precompile += %w( admin.js admin.css )
|
||||
end
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in the app/assets
|
||||
# folder are already added.
|
||||
Rails.application.config.assets.precompile += %w( markdown-buttons.png )
|
||||
|
||||
# Disable concurrent asset compilation to prevent segfault # https://github.com/sass/sassc-ruby/issues/197
|
||||
# Reproduce: `rake assets:clobber`, `rake assets:precompile`. If the command succeeds, it worked
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Define an application-wide content security policy
|
||||
@ -11,10 +13,7 @@
|
||||
# policy.object_src :none
|
||||
# policy.script_src :self, :https
|
||||
# policy.style_src :self, :https
|
||||
#
|
||||
# # You need to allow webpack-dev-server host as allowed origin for connect-src.
|
||||
# # This can be done in Rails 5.2+ for development environment in the CSP initializer
|
||||
# # config/initializers/content_security_policy.rb with a snippet like this:
|
||||
# # If you are using webpack-dev-server then specify webpack-dev-server host
|
||||
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
|
||||
|
||||
# # Specify URI for violation reports
|
||||
@ -24,6 +23,9 @@
|
||||
# If you are using UJS then enable automatic nonce generation
|
||||
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
|
||||
|
||||
# Set the nonce only to specific directives
|
||||
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
|
||||
|
||||
# Report CSP violations to a specified URI
|
||||
# For further information see the following documentation:
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
||||
|
@ -1,8 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'docker_client'
|
||||
|
||||
DockerClient.initialize_environment unless Rails.env.test? && `which docker`.blank?
|
||||
|
||||
return if Rake.application.top_level_tasks.to_s.include?('db:')
|
||||
|
||||
if ApplicationRecord.connection.tables.present? &&
|
||||
DockerContainerPool.config[:active]
|
||||
# no op
|
||||
end
|
||||
|
@ -1 +1,5 @@
|
||||
Docker::Container.send(:include, DockerContainerMixin)
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'docker_container_mixin'
|
||||
|
||||
Docker::Container.include DockerContainerMixin
|
||||
|
@ -1,9 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'code_ocean/config'
|
||||
|
||||
return unless CodeOcean::Config.new(:code_ocean).read[:prometheus_exporter][:enabled] && !defined?(::Rails::Console)
|
||||
return if %w[db: assets:].any? { |task| Rake.application.top_level_tasks.to_s.include?(task) }
|
||||
|
||||
# Add metric callbacks to all models
|
||||
ApplicationRecord.include Prometheus::Record
|
||||
ActiveSupport.on_load :active_record do
|
||||
include Prometheus::Record
|
||||
end
|
||||
|
||||
# Initialization is performed in config/application.rb
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RailsAdmin.config do |config|
|
||||
|
||||
### Popular gems integration
|
||||
|
@ -4,8 +4,9 @@
|
||||
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
||||
# and maximum; this matches the default thread size of Active Record.
|
||||
#
|
||||
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
||||
threads threads_count, threads_count
|
||||
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
||||
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
||||
threads min_threads_count, max_threads_count
|
||||
|
||||
# Specifies the `port` that Puma will listen on to receive requests; default is 7000.
|
||||
#
|
||||
@ -15,8 +16,11 @@ port ENV.fetch("PORT") { 7000 }
|
||||
#
|
||||
environment ENV.fetch("RAILS_ENV") { "development" }
|
||||
|
||||
# Specifies the `pidfile` that Puma will use.
|
||||
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
||||
|
||||
# Specifies the number of `workers` to boot in clustered mode.
|
||||
# Workers are forked webserver processes. If using threads and workers together
|
||||
# Workers are forked web server processes. If using threads and workers together
|
||||
# the concurrency of the application would be max `threads` * `workers`.
|
||||
# Workers do not work on JRuby or Windows (both of which do not support
|
||||
# processes).
|
||||
|
@ -1,6 +1,6 @@
|
||||
%w(
|
||||
.ruby-version
|
||||
.rbenv-vars
|
||||
tmp/restart.txt
|
||||
tmp/caching-dev.txt
|
||||
).each { |path| Spring.watch(path) }
|
||||
Spring.watch(
|
||||
".ruby-version",
|
||||
".rbenv-vars",
|
||||
"tmp/restart.txt",
|
||||
"tmp/caching-dev.txt"
|
||||
)
|
||||
|
Reference in New Issue
Block a user