Elastic Beanstalk - 使用Github Gems部署Rails

时间:2013-08-28 17:15:08

标签: ruby-on-rails ruby git elastic-beanstalk

我已经在SO上讨论过使用:git讨论GemFile的其他几个主题,但这些解决方案对我来说似乎没有用。

这是我的.ebextensions / ruby​​.config文件:

option_settings:
  - option_name: BUNDLE_DISABLE_SHARED_GEMS
    value: "1"
  - option_name: BUNDLE_PATH
    value: "vendor/bundle"

packages:
  yum:
    git: []

container_commands:
  01bundle:
    command: bundle --deployment

这是我在GemFile中使用Github的地方:

gem 'themes_for_rails', :git => 'https://github.com/digitalmoksha/themes_for_rails.git'

最后,我在与这个宝石相关的production.log中得到的错误不在这里:

I, [2013-08-28T13:29:26.979524 #26738]  INFO -- : Start adding themes to assets [true]
I, [2013-08-28T13:30:36.528844 #26808]  INFO -- : Start adding themes to assets [true]
I, [2013-08-28T13:32:47.069202 #26901]  INFO -- : Start adding themes to assets [true]
I, [2013-08-28T13:32:48.254604 #26913]  INFO -- : Started GET "/" for 123.456.789.10 at 2013-08-28 13:32:48 +0000
I, [2013-08-28T13:32:48.299025 #26913]  INFO -- : Processing by StaticController#index as HTML
I, [2013-08-28T13:32:48.323622 #26913]  INFO -- :   Rendered static/index.html.erb within layouts/application (0.7ms)
I, [2013-08-28T13:32:48.331925 #26913]  INFO -- : Completed 500 Internal Server Error in 32ms
F, [2013-08-28T13:32:48.334631 #26913] FATAL -- : 
ActionView::Template::Error (undefined method `base_theme_stylesheet_path' for #<StaticController:0x00000003e16a10>):
    3: <head>
    4:   <title>Boundless</title>
    5:   <%= stylesheet_link_tag     "application", media: "all", "data-turbolinks-track" => true %>
    6:   <%= stylesheet_link_tag     current_theme_stylesheet_path('application'), media: "all", "data-turbolinks-track" => true %>
    7:   <%= javascript_include_tag  "application", "data-turbolinks-track" => true %>
    8:   <%= javascript_include_tag  current_theme_javascript_path('application'), "data-turbolinks-track" => true %>
    9:   <%= csrf_meta_tags %>
  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__2276887207485791953_34113280'

但是,我可以清楚地看到宝石包装在/var/log/eb-tools.log中

Using themes_for_rails (0.5.2) from https://github.com/digitalmoksha/themes_for_rails.git (at master) 
Using turbolinks (1.3.0) 
Using uglifier (2.2.0) 
Your bundle is complete! It was installed into ./vendor/bundle

这是我的完整日志文件快照:https://gist.github.com/holtkampw/255d7bb00407fc615c76

关于如何才能使其正常工作的任何想法?也许我的.ebextenions文件不正确?

2 个答案:

答案 0 :(得分:2)

我遇到了与主动管理员相同的问题。您可以将gem放入vendor文件夹中。为我工作。

将它放在你的宝石文件中:

gem 'themes_for_rails', path: 'vendor/themes_for_rails', require: 'themes_for_rails'

您需要将此代码保存到/.ebextensions/ruby.config文件中:

option_settings:
  - option_name: BUNDLE_DISABLE_SHARED_GEMS
  value: "1"
  - option_name: BUNDLE_PATH
  value: "vendor/bundle"

不要忘记将gem的git内容提取到 vendor / themes_for_rails 文件夹中。

答案 1 :(得分:1)

This gist将使其行为与大多数rails环境一样。当我遇到来自git repo的gem的同样问题时,我开始在我们的部署中使用它。

根据我的理解(至少我记得),理由是git位置是不受信任的来源,并且可能会因为添加/回收实例而导致部署不稳定或不可重现。虽然我同意,但我仍然希望在我想要的时候使用它们。