* Bump rubocop from 1.15.0 to 1.16.0 Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.15.0 to 1.16.0. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.15.0...v1.16.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Enable new cops and fix violations Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: rhymes <github@rhymes.dev>
63 lines
1.9 KiB
Ruby
63 lines
1.9 KiB
Ruby
# rubocop:disable Style/TopLevelMethodDefinition
|
|
require "mini_magick"
|
|
|
|
# Carrierwave uses MiniMagick for image processing. To prevent server timeouts
|
|
# we are setting the MiniMagick timeout lower.
|
|
MiniMagick.configure do |config|
|
|
config.timeout = 10
|
|
end
|
|
|
|
def local_storage_config
|
|
CarrierWave.configure do |config|
|
|
config.storage = :file
|
|
config.enable_processing = !Rails.env.test? # disabled for test
|
|
config.asset_host = if Rails.env.production?
|
|
"https://#{ApplicationConfig['APP_DOMAIN']}"
|
|
end
|
|
end
|
|
end
|
|
|
|
def standard_production_config
|
|
CarrierWave.configure do |config|
|
|
config.storage = :fog
|
|
config.fog_directory = ApplicationConfig["AWS_BUCKET_NAME"]
|
|
config.fog_provider = "fog/aws"
|
|
config.fog_attributes = { cache_control: "public, max-age=#{365.days.to_i}" }
|
|
config.fog_credentials = {
|
|
provider: "AWS",
|
|
aws_access_key_id: ApplicationConfig["AWS_ID"],
|
|
aws_secret_access_key: ApplicationConfig["AWS_SECRET"],
|
|
region: ApplicationConfig["AWS_UPLOAD_REGION"].presence || ApplicationConfig["AWS_DEFAULT_REGION"]
|
|
}
|
|
end
|
|
end
|
|
|
|
def forem_cloud_config
|
|
CarrierWave.configure do |config|
|
|
config.storage = :fog
|
|
config.fog_directory = ApplicationConfig["AWS_BUCKET_NAME"]
|
|
config.fog_provider = "fog/aws"
|
|
config.asset_host = "https://#{ApplicationConfig['APP_DOMAIN']}/remoteimages"
|
|
config.fog_public = false
|
|
config.fog_credentials = {
|
|
provider: "AWS",
|
|
use_iam_profile: true,
|
|
region: "us-east-2"
|
|
}
|
|
end
|
|
end
|
|
|
|
Rails.application.reloader.to_prepare do
|
|
if Rails.env.production? && ENV["FILE_STORAGE_LOCATION"] != "file"
|
|
if ENV["FOREM_CONTEXT"] == "forem_cloud"
|
|
forem_cloud_config
|
|
elsif ApplicationConfig["AWS_ID"].present?
|
|
standard_production_config
|
|
else
|
|
local_storage_config
|
|
end
|
|
else
|
|
local_storage_config
|
|
end
|
|
end
|
|
# rubocop:enable Style/TopLevelMethodDefinition
|