让Heroku将资产预编译到Amazon aws s3
我的问题是让AWS S3为我的heroku应用程序提供静态资产 一切都在本地工作,我运行我的rake任务,然后将资产预编译到AWS(尽管终端中从来没有任何输出?) 然后到heroku,在那里我像这样设置我的ENV变量让Heroku将资产预编译到Amazon aws s3,heroku,amazon-web-services,sinatra,assets,rake-task,Heroku,Amazon Web Services,Sinatra,Assets,Rake Task,我的问题是让AWS S3为我的heroku应用程序提供静态资产 一切都在本地工作,我运行我的rake任务,然后将资产预编译到AWS(尽管终端中从来没有任何输出?) 然后到heroku,在那里我像这样设置我的ENV变量 heroku config:add aws_access_key=mysecretkey aws_secret_key=mypublickey aws_bucket=mybucketname 我有两个桶,一个用于开发,一个用于生产。我是否需要在heroku:config中设置其
heroku config:add aws_access_key=mysecretkey aws_secret_key=mypublickey aws_bucket=mybucketname
我有两个桶,一个用于开发,一个用于生产。我是否需要在heroku:config中设置其他内容
这是我到目前为止得到的
config.rb
AssetSync.configure do |con|
con.fog_provider = 'AWS'
con.fog_region = 'eu-west-1'
con.fog_directory = ENV['aws_bucket']
con.aws_access_key_id = ENV['aws_access_key']
con.aws_secret_access_key = ENV['aws_secret_key']
con.prefix = "assets"
con.public_path = Pathname("./public")
end
这里的问题是,heroku将读取和使用其中的多少,我知道我必须在heroku中显式设置ENV,但它会读取其余部分并执行任务的其余部分吗,即它会读取前缀、公共路径等
耙子
require 'bundler/setup'
Bundler.require(:default)
require 'active_support/core_ext'
require './config/env' if File.exists?('config/env.rb')
require './config/config'
namespace :assets do
desc "Precompile assets"
task :precompile do
AssetSync.sync
end
结束
跑步时
heroku run rake assets:precompile
我得到输出
`rake assets:precompile` attached to terminal...up, run.2942 The source :rubygems is deprecated because HTTP requests are insecure. Please change your source to 'https://rubygems.org (in /app)
然后它就返回到终端,我希望有一个列表,其中列出了执行任务时要编译的所有资产。在aws中检查我的桶时,它是空的
编辑
heroku日志后的输出——tail
大约15分钟后添加了更多
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: An existing connection was forcibly closed by the remote host
(Errno::ECONNRESET)
Command: heroku logs --tail
Version: heroku-gem/2.35.0 (i386-mingw32) ruby/1.9.3
这是由于文件中说明的源导致的绑定器错误。它与资产汇编本身无关 指明
source 'https://rubygems.org'
在文件的顶部。还有错误吗?heroku对这些错误保持沉默。您可以尝试在本地模拟资产编译。创建一个gemset或其他东西,并尝试执行该任务。我最近遇到了heroku不编译资产的问题,因为我有一些定制的rake任务无法加载到heroku上,因为缺少Gems。我看不到,资产编译在本地工作,它是为heroku编译的,heroku是开放两个终端的发行商,转到这两个目录中的项目目录,在其中一个目录中运行'heroku logs--tail',在另一个目录中运行'heroku run rake assets:precompile'。请发布日志的输出。@MoMolog和其他人-为什么在生产时编译资产,为什么不在本地编译并推送到AWS存储桶?我自己没有使用过它,所以我只是想知道。更新,我刚刚运行了heroku run rake assets:precompile我在两个环境中都将bucket名称更改为相同的名称,以前在本地使用的名称是applecatering,通过heroku config:add我将其设置为applecateringprod,所以现在都设置为applecatering。所以现在我检查了水桶,确定我的资产。。我犯了一个大错误,有两个BucketName吗?现在的问题是,我如何判断我的资产是否真的由AWS提供服务?
source 'https://rubygems.org'