Merge branch 'feature/rails_6' into 'develop'
Upgrade to Rails 6 See merge request gab/social/gab-social!52
This commit is contained in:
10
config/cable.yml
Normal file
10
config/cable.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
development:
|
||||
adapter: async
|
||||
|
||||
test:
|
||||
adapter: test
|
||||
|
||||
production:
|
||||
adapter: redis
|
||||
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
|
||||
channel_prefix: gab_social_production
|
||||
@@ -9,21 +9,18 @@ development:
|
||||
<<: *default
|
||||
adapter: postgresql_makara
|
||||
prepared_statements: false
|
||||
database: <%= ENV['DB_NAME'] || 'gabsocial_development' %>
|
||||
username: <%= ENV['DB_USER'] %>
|
||||
password: <%= ENV['DB_PASS'] %>
|
||||
host: <%= ENV['DB_HOST'] %>
|
||||
port: <%= ENV['DB_PORT'] %>
|
||||
makara:
|
||||
id: postgres
|
||||
sticky: true
|
||||
connections:
|
||||
- role: master
|
||||
blacklist_duration: 0
|
||||
url: postgresql://<%= ENV['DB_USER']%>:<%= ENV['DB_PASS'] %>@<%= ENV['DB_HOST'] %>:<%= ENV['DB_PORT'] %>/<%= ENV['DB_NAME'] || 'gabsocial_development' %>
|
||||
- role: slave
|
||||
url: postgresql://<%= ENV['DB_USER']%>:<%= ENV['DB_PASS'] %>@<%= ENV['DB_HOST'] %>:<%= ENV['DB_PORT'] %>/<%= ENV['DB_NAME'] || 'gabsocial_development' %>
|
||||
|
||||
# database: <%= ENV['DB_NAME'] || 'gabsocial_development' %>
|
||||
# username: <%= ENV['DB_USER'] %>
|
||||
# password: <%= ENV['DB_PASS'] %>
|
||||
# host: <%= ENV['DB_HOST'] %>
|
||||
# port: <%= ENV['DB_PORT'] %>
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
|
||||
@@ -17,7 +17,7 @@ Rails.application.configure do
|
||||
if Rails.root.join('tmp/caching-dev.txt').exist?
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
config.cache_store = :redis_store, ENV['REDIS_URL'], REDIS_CACHE_PARAMS
|
||||
config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS.merge(url: ENV['REDIS_URL'])
|
||||
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => "public, max-age=#{2.days.to_i}",
|
||||
@@ -38,6 +38,9 @@ Rails.application.configure do
|
||||
config.x.vapid_private_key = vapid_key.private_key
|
||||
config.x.vapid_public_key = vapid_key.public_key
|
||||
|
||||
# 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.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
@@ -49,6 +52,9 @@ Rails.application.configure do
|
||||
# Raise an error on page load if there are pending migrations.
|
||||
config.active_record.migration_error = :page_load
|
||||
|
||||
# Highlight code that triggered database queries in logs.
|
||||
config.active_record.verbose_query_logs = true
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
@@ -76,6 +82,8 @@ Rails.application.configure do
|
||||
# Otherwise, use letter_opener, which launches a browser window to view sent mail.
|
||||
config.action_mailer.delivery_method = (ENV['HEROKU'] || ENV['VAGRANT'] || ENV['REMOTE_DEV']) ? :letter_opener_web : :letter_opener
|
||||
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
|
||||
config.after_initialize do
|
||||
Bullet.enable = true
|
||||
Bullet.bullet_logger = true
|
||||
|
||||
@@ -41,9 +41,20 @@ 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).
|
||||
config.active_storage.service = :local
|
||||
|
||||
# Allow to specify public IP of reverse proxy if it's needed
|
||||
config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split.map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present?
|
||||
|
||||
# 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.*/ ]
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
config.force_ssl = true
|
||||
|
||||
# Use the lowest log level to ensure availability of diagnostic information
|
||||
# when problems arise.
|
||||
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym
|
||||
@@ -52,7 +63,7 @@ Rails.application.configure do
|
||||
config.log_tags = [:request_id]
|
||||
|
||||
# Use a different cache store in production.
|
||||
config.cache_store = :redis_store, ENV['CACHE_REDIS_URL'], REDIS_CACHE_PARAMS
|
||||
config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS.merge(url: ENV['CACHE_REDIS_URL'])
|
||||
|
||||
# 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.
|
||||
@@ -102,4 +113,25 @@ Rails.application.configure do
|
||||
}
|
||||
|
||||
config.x.otp_secret = ENV.fetch('OTP_SECRET')
|
||||
|
||||
# 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
|
||||
|
||||
@@ -27,6 +27,9 @@ Rails.application.configure do
|
||||
# and should not be used.
|
||||
config.cache_store = :memory_store
|
||||
|
||||
# Store uploaded files on the local file system in a temporary directory.
|
||||
config.active_storage.service = :test
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
|
||||
53
config/initializers/new_framework_defaults_6_0.rb
Normal file
53
config/initializers/new_framework_defaults_6_0.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains migration options to ease your Rails 6.0 upgrade.
|
||||
#
|
||||
# Once upgraded flip defaults one by one to migrate to the new default.
|
||||
#
|
||||
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
|
||||
|
||||
# Don't force requests from old versions of IE to be UTF-8 encoded.
|
||||
Rails.application.config.action_view.default_enforce_utf8 = false
|
||||
|
||||
# Embed purpose and expiry metadata inside signed and encrypted
|
||||
# cookies for increased security.
|
||||
#
|
||||
# This option is not backwards compatible with earlier Rails versions.
|
||||
# It's best enabled when your entire app is migrated and stable on 6.0.
|
||||
# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
|
||||
|
||||
# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
|
||||
# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
|
||||
|
||||
# Return false instead of self when enqueuing is aborted from a callback.
|
||||
Rails.application.config.active_job.return_false_on_aborted_enqueue = true
|
||||
|
||||
# Send Active Storage analysis and purge jobs to dedicated queues.
|
||||
Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
|
||||
Rails.application.config.active_storage.queues.purge = :active_storage_purge
|
||||
|
||||
# When assigning to a collection of attachments declared via `has_many_attached`, replace existing
|
||||
# attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
|
||||
Rails.application.config.active_storage.replace_on_assign_to_many = true
|
||||
|
||||
# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
|
||||
#
|
||||
# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
|
||||
# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
|
||||
# If you send mail in the background, job workers need to have a copy of
|
||||
# MailDeliveryJob to ensure all delivery jobs are processed properly.
|
||||
# Make sure your entire app is migrated and stable on 6.0 before using this setting.
|
||||
Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
||||
|
||||
# Enable the same cache key to be reused when the object being cached of type
|
||||
# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
|
||||
# of the relation's cache key into the cache version to support recycling cache key.
|
||||
Rails.application.config.active_record.collection_cache_versioning = true
|
||||
|
||||
|
||||
# The Rails 6 default autoloader is Zeitwerk. Zeitwerk has specific expectations on where certain
|
||||
# classes should be defined. It also requires that constants are not autoloaded in initializers.
|
||||
# Enabling Zeitwerk would be good, but it'll take some work. Using the :classic autoloader gives
|
||||
# us the same autoloading that Rails 5.2 had.
|
||||
# Rails.application.config.autoloader = :zeitwerk
|
||||
Rails.application.config.autoloader = :classic
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if ENV['STATSD_ADDR'].present?
|
||||
if false && ENV['STATSD_ADDR'].present?
|
||||
host, port = ENV['STATSD_ADDR'].split(':')
|
||||
|
||||
statsd = ::Statsd.new(host, port)
|
||||
|
||||
@@ -12,10 +12,4 @@ workers ENV.fetch('WEB_CONCURRENCY') { 2 }
|
||||
|
||||
preload_app!
|
||||
|
||||
on_worker_boot do
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
ActiveRecord::Base.establish_connection
|
||||
end
|
||||
end
|
||||
|
||||
plugin :tmp_restart
|
||||
|
||||
34
config/storage.yml
Normal file
34
config/storage.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
test:
|
||||
service: Disk
|
||||
root: <%= Rails.root.join("tmp/storage") %>
|
||||
|
||||
local:
|
||||
service: Disk
|
||||
root: <%= Rails.root.join("storage") %>
|
||||
|
||||
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
||||
# amazon:
|
||||
# service: S3
|
||||
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
||||
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
||||
# region: us-east-1
|
||||
# bucket: your_own_bucket
|
||||
|
||||
# Remember not to checkin your GCS keyfile to a repository
|
||||
# google:
|
||||
# service: GCS
|
||||
# project: your_project
|
||||
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
||||
# bucket: your_own_bucket
|
||||
|
||||
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
||||
# microsoft:
|
||||
# service: AzureStorage
|
||||
# storage_account_name: your_account_name
|
||||
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
||||
# container: your_container_name
|
||||
|
||||
# mirror:
|
||||
# service: Mirror
|
||||
# primary: local
|
||||
# mirrors: [ amazon, google, microsoft ]
|
||||
Reference in New Issue
Block a user