代码之家  ›  专栏  ›  技术社区  ›  Luiz Aoqui

Phusion Passenger Docker图像上的错误“在任何源中找不到rake-10.5.0”

  •  2
  • Luiz Aoqui  · 技术社区  · 8 年前

    我正在尝试使用Docker和 Phusion Passenger Ruby base image ,但每当我尝试从浏览器访问应用程序时,我都会收到以下错误:

    web_1 | [ 2016-02-08 04:18:44.6861 31/7ff292141700     age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application   /home/app/webapp: An error occurred while starting up the preloader.
    web_1 |   Error ID: d3103e16
    web_1 |   Error details saved to: /tmp/passenger-error-EwymlW.html
    web_1 |   Message from application: <p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:</p>
    web_1 |
    web_1 |   <pre class="commands">bundle install</pre>
    web_1 |
    web_1 | <p>If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:</p>
    web_1 |
    web_1 | <ol>
    web_1 |   <li>Is this app supposed to be run as the <code>app</code> user?</li>
    web_1 |   <li>Is this app being run on the correct Ruby interpreter? Below you will
    web_1 |       see which Ruby interpreter Phusion Passenger attempted to use.</li>
    web_1 | </ol>
    web_1 |
    web_1 | <p>-------- The exception is as follows: -------</p>
    web_1 | Could not find rake-10.5.0 in any of the sources (Bundler::GemNotFound)
    web_1 | <pre>  /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in `block in materialize&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `map!&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `materialize&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in `specs&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in `specs_for&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in `requested_specs&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in `requested_specs&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in `setup&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler.rb:127:in `setup&#39;
    web_1 |   /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in `&lt;top (required)&gt;&#39;
    web_1 |   /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require&#39;
    web_1 |   /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require&#39;
    web_1 |   /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:430:in `activate_gem&#39;
    web_1 |   /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:297:in `block in run_load_path_setup_code&#39;
    web_1 |   /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:435:in `running_bundler&#39;
    web_1 |   /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:296:in `run_load_path_setup_code&#39;
    web_1 |   /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app&#39;
    web_1 |   /usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `&lt;module:App&gt;&#39;
    web_1 |   /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `&lt;module:PhusionPassenger&gt;&#39;
    web_1 |   /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `&lt;main&gt;&#39;</pre>
    web_1 |
    web_1 |
    web_1 | [ 2016-02-08 04:18:44.6935 31/7ff293143700 age/Cor/Con/CheckoutSession.cpp:277 ]: [Client 1-2] Cannot checkout session because a spawning error occurred. The identifier of the error is d3103e16. Please see earlier logs for details about the error.
    

    这是我的 Dockerfile :

    FROM phusion/passenger-ruby22:0.9.18
    
    # Set correct environment variables.
    ENV HOME /root
    
    # Use baseimage-docker's init process.
    CMD ["/sbin/my_init"]
    
    # Enable Nginx/Passenger
    RUN rm -f /etc/service/nginx/down
    
    # Enable portals virtual host
    RUN rm /etc/nginx/sites-enabled/default
    COPY portals.conf /etc/nginx/sites-enabled/portals.conf
    RUN mkdir /home/app/webapp
    
    # Load env vars into nginx
    COPY rails-env.conf /etc/nginx/main.d/rails-env.conf
    
    # Install gems dependencies
    COPY Gemfile* /tmp/
    WORKDIR /tmp
    RUN bundle install
    
    # Copy rails app
    WORKDIR /home/app/webapp
    COPY . ./
    RUN chown -R app:app ./
    
    # Clean up APT when done.
    RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
    

    我试着运行bundler作为 RUN bundle install --deployment 但效果并不好。我正在通过 RAILS_ENV PASSENGER_APP_ENV 通过 rails-env.conf 文件,它们都被设置为生产(根据乘客图像文档,这是默认值)。

    如果我 docker exec -it bash <ID> 进入容器并运行 gem list 我看到所有的宝石都安装好了,所以我不知道怎么了。

    2 回复  |  直到 8 年前
        1
  •  2
  •   Scott Jacobsen    8 年前

    此错误是由于软件过期造成的。因为乘客图像不经常更新,所以在您的 Dockerfile 。这是我通常设置 Dockerfile文件 基于phusion图像:

    FROM phusion/passenger-ruby22:0.9.18
    
    ENV SYSTEM_UPDATE=1
    RUN apt-get update \
    && apt-get upgrade -y -o Dpkg::Options::="--force-confold" \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*
    
    WORKDIR /home/app
    COPY Gemfile /home/app/Gemfile
    COPY Gemfile.lock /home/app/Gemfile.lock
    RUN gem update --system && \
    gem update bundler && \
    bundle install --jobs 4 --retry 5
    
    # The rest of your app setup here
    
    ENTRYPOINT ["/sbin/my_init", "--"]
    

    SYSTEM_UPDATE 只是一个缓存破坏者变量。当我启动时,所有的包都将在下一个docker构建中更新。它应该经常颠簸。

    我还保证 gem bundler 在运行前完全更新 bundle install .

    此外,复制您的 Gemfile Gemfile.lock 到tmp目录,只需将其复制到应用程序目录。

    你可以删除你的决赛 Clean up APT when done. 命令-那真的不是合适的地方。应该有一个 RUN 运行所有 apt-get 命令。

    看看 https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/ 有关设置Dockerfile的最佳实践,特别是关于使用apt-get的部分。

        2
  •  -1
  •   PyWebDesign    8 年前

    对我来说,瑞克就在那里,我用

    rake rails:update

    玩得高兴