我已经使用asset-sync和fog gem将资源上传到aws s3。我可以在部署时将预编译资产文件上传到aws-s3但是花费了大量时间。部署未完成然后它在bundle exec上停止rake assets:预编译命令。
宝石文件:
gem "fog", "~>1.20", require: "fog/aws/storage"
gem 'asset_sync'
资产同步配置文件:
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.aws_access_key_id = "Your aws access key"
config.aws_secret_access_key = "Your aws secret access key"
config.fog_directory = ENV['FOGDIRECTORY']
config.fog_region = 'us-west-2'
end
Staging.rb文件:
config.assets.enabled = true
config.assets.digest = true
config.action_controller.asset_host = "http://djrcjofcge7nb.cloudfront.net"
config.action_mailer.asset_host = "http://djrcjofcge7nb.cloudfront.net"
config.assets.initialize_on_precompile = true
答案 0 :(得分:0)
在staging.rb
文件中添加以下配置
config.assets.compile = true
config.eager_load = true