简体   繁体   English

回形针和Capistrano的问题

[英]issue with Paperclip and Capistrano

I have deployed a Rails 5 app on a Ubuntu 16.04 server. 我已经在Ubuntu 16.04服务器上部署了Rails 5应用程序。 There is however a problem with the Paperclip configuration. 但是,回形针配置存在问题。

I'm using the Figaro gem to store my environment variables. 我正在使用Figaro gem来存储我的环境变量。 My paperclip configuration looks like this: 我的回形针配置如下所示:

config/environments/production.rb

config.paperclip_defaults = {
  storage: :s3,
  bucket: 'anthonycandaele',
  s3_region: 'eu-west-1',
  s3_credentials: {
    access_key_id: ENV.fetch("AWS_ACCESS_KEY_ID"),
    secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY"),
    s3_host_name: "s3-eu-west-1.amazonaws.com",
  }

} }

this worked fine in development. 这在开发中效果很好。

But when I try to deploy my app, I get a failure when I try to deploy with Capistrano: 但是,当我尝试部署我的应用程序时,尝试通过Capistrano进行部署时会失败:

log/capistrano.log

INFO [3b1c6af3] Running bundle exec rake assets:precompile as   deploy@146.185.164.246
3245  DEBUG [3b1c6af3] Command: cd   /opt/www/personalsite/releases/20170119174557 && ( export    RAILS_ENV="production" ; bundle exec rake assets:precompile )
3246  DEBUG [3b1c6af3] »·rake aborted!
3247  DEBUG [3b1c6af3] »·KeyError: key not found: "AWS_ACCESS_KEY_ID"

So I tried to fix the problem with adjusting the Paperclip configuration: 因此,我尝试通过调整回形针配置来解决该问题:

config.paperclip_defaults = {
storage: :s3,
bucket: 'anthonycandaele',
s3_region: 'eu-west-1',
s3_credentials: {
  access_key_id: ENV["AWS_ACCESS_KEY_ID"],
  secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
  s3_host_name: "s3-eu-west-1.amazonaws.com",
}

} }

now I'm able to deploy with Capistrano, but when I try to upload a file with the app, I'm getting a missingcredentialserror with AWS: 现在我可以使用Capistrano进行部署,但是当我尝试使用该应用程序上传文件时,AWS出现了缺少凭证错误:

Aws::Errors::MissingCredentialsError (unable to sign request without credentials set):

Has anyone experience with using Paperclip and storing the environment variables with Figaro? 有没有人有过使用Paperclip以及使用Figaro存储环境变量的经验?

Thanks for your help, 谢谢你的帮助,

Anthony 安东尼

我可以通过设置远程config / application.yml文件来解决此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM