0
votes

I'm having problems deploying my docker container, primarily due to bundler not being able to execute it's install command. Running bundle install locally with passenger seems to work just fine, only the deployment procedure causes problems upon setting up the gems.

I am relatively new to Docker and I wouldn't call myself a Rails expert. That said, I have difficulties understanding how exactly bundler manages to mess this whole thing up in this way (especially in conjunction with Docker).

I'm using the passenger-docker base image if that's of any relevance.

Here is my Gemfile:

gem 'doorkeeper'
gem 'doorkeeper-jwt'
gem 'aws-sdk-rails'
gem 'rack-cors', :require => 'rack/cors'
gem 'active_model_serializers', github: 'rails-api/active_model_serializers'
gem 'passenger'
gem 'rails', '4.2.6'
gem 'rails-api'
gem 'pg'
gem 'devise'
gem 'schema_plus'
gem 'pusher'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do

  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'rspec-rails'
  gem 'factory_girl_rails', '~> 4.0'
  gem 'database_cleaner'

end

And here is (part of) the Dockerfile:

RUN mkdir /home/app/myapp
WORKDIR /home/app/myapp

COPY Gemfile /home/app/myapp/
COPY Gemfile.lock /home/app/myapp/
RUN chown -R app:app /home/app/myapp
RUN sudo -u app bundle install --deployment --verbose --path vendor/cache

ADD . /home/app/myapp
RUN chown -R app:app /home/app/myapp

When I try to deploy, I get the following error:

Message from application:

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:

bundle install

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:

  1. Is this app supposed to be run as the app user?
  2. Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.

-------- The exception is as follows: -------

Could not find rake-11.1.2 in any of the sources (Bundler::GemNotFound)
 
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in
block in materialize'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in
map!'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in materialize'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in
specs'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in specs_for'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in
requested_specs'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in requested_specs'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in
setup'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler.rb:127:in setup'
/var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in
<top (required)>'
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in require&#39;
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:430:in activate_gem&#39;
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:297:in
block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:435:in running_bundler&#39;
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:296:in
run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in preload_app&#39;
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in
<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in &lt;module:PhusionPassenger&gt;&#39;
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in
<main>'
1

1 Answers

0
votes

There are too many variables here. It's not clear what 'deploy' means in your question? "When I try to deploy" -- is that something like docker run ... or docker-compose ...? Or is a Heroku/AWS/DigitalOcean/CF type push? Are you running Docker natively locally, boot2Docker, remote?

Generally, is it possible that from within the container, there is no outbound connectivity? Are you behind a proxy? If so the same proxy setup may need to be carried over inside the container -- and how that happens depends on the proxy setup and the Docker specifics.

If you are able to add the installation of any network tools to your Dockerfile, then try something like docker exec <container_id> curl rubygems.org (or if you haven't a running container, docker run <image_id> curl rubygems.org

Hope this helps get you started in the right direction.