Skip to content

Commit

Permalink
don't initialize AWS client when precompiling the assets (Docker)
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Aug 31, 2024
1 parent 8c7b509 commit b7c02e2
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions config/initializers/carrierwave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,35 @@
config.root = File.join(Rails.root, 'public')

when :production
# config.storage = :file
# config.root = File.join(Rails.root, 'public')

# # put your CDN host below instead
# # config.asset_host = 'http://cdn.example.com'

# # You can also use Amazon S3 instead. The following configuration works for AWS
# #
# # WARNING: add the "carrierwave-aws" gem in your Rails app Gemfile.
# # More information here: https://github.com/sorentwo/carrierwave-aws
#
config.storage = :aws
config.aws_bucket = ENV['S3_BUCKET']
config.aws_acl = 'public-read'

config.aws_credentials = {
access_key_id: ENV['S3_KEY_ID'],
secret_access_key: ENV['S3_SECRET_KEY'],
region: ENV['S3_BUCKET_REGION']
}

# Put your CDN host below instead
if ENV['S3_ASSET_HOST_URL'].present?
config.asset_host = ENV['S3_ASSET_HOST_URL']
begin
# context: when we're precompiling the assets in the Dockerfile
break if ENV['S3_BUCKET'].blank?

# config.storage = :file
# config.root = File.join(Rails.root, 'public')

# # put your CDN host below instead
# # config.asset_host = 'http://cdn.example.com'

# # You can also use Amazon S3 instead. The following configuration works for AWS
# #
# # WARNING: add the "carrierwave-aws" gem in your Rails app Gemfile.
# # More information here: https://github.com/sorentwo/carrierwave-aws
#
config.storage = :aws
config.aws_bucket = ENV['S3_BUCKET']
config.aws_acl = 'public-read'

config.aws_credentials = {
access_key_id: ENV['S3_KEY_ID'],
secret_access_key: ENV['S3_SECRET_KEY'],
region: ENV['S3_BUCKET_REGION']
}

# Put your CDN host below instead
if ENV['S3_ASSET_HOST_URL'].present?
config.asset_host = ENV['S3_ASSET_HOST_URL']
end
end

else
Expand Down

0 comments on commit b7c02e2

Please sign in to comment.