Bundler fails in Docker mirror service with local gem paths

I’m using a docker-compose.yml file that looks like.

version: '2'

    tty: true
    image: ruby:2.4
      - 3000:3000
      - .:/app
      - .env

    build: .
    command: bundle exec sidekiq

And sidekiq works fine and builds from the same Dockerfile info that the myapp generates. But when I add some gem dependencies in my Gemfile that require local directory access it fails.

  • Fetching git behind proxy in docker container
  • Docker bundle install cache issues when updating gems
  • Bundling from Github in a Dockerfile
  • How do I update Gemfile.lock on my Docker host?
  • Rails + Docker: ffi gem update today broke deploy?
  • Could not install gems on docker container
  • Adding this to Gemfile and bundle update won’t allow sidekiq to build.

    gem 'rails-assets-jplayer',   path: 'lib/gems/rails-assets-jplayer'
    gem 'rails-assets-bootstrap', path: 'lib/gems/rails-assets-bootstrap'
    gem 'rails-assets-jquery',    path: 'lib/gems/rails-assets-jquery'
    gem 'rails-assets-jquery-ui', path: 'lib/gems/rails-assets-jquery-ui'

    After adding these I get this error only from sidekiq and not from myapp (it works).

    myapp uses an image, skipping
    Building sidekiq
    Step 1/4 : FROM ruby:2.4-onbuild
    # Executing 4 build triggers...
    Step 1/1 : COPY Gemfile /usr/src/app/
     ---> Using cache
    Step 1/1 : COPY Gemfile.lock /usr/src/app/
     ---> Using cache
    Step 1/1 : RUN bundle install
     ---> Running in ccfd0fc73542
    The path `/usr/src/app/lib/gems/rails-assets-jquery-ui` does not exist.
    ERROR: Service 'sidekiq' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 13

    I can’t figure out if the directory structure is different in sidekiq or if it really doesn’t have access to just this subfolder. Is there a way I can introspect the path that the bundle install is happening in? And more importantly; how can I get the local gems to work in this second container?

    If you plan on asking about a Dockerfile — don’t. It’s purely what docker-compose generated and hasn’t been modified. Like I said both of these docker images work if the Gemfile doesn’t have the local gems required in it.

  • Building a docker image (.NET Core) and uploading it to Google Container Engine?
  • Is it possible to install Docker on Raspberry Pi 2 Model B?
  • how to create an InfluxDB user in a Dockerfile
  • Docker container knows rbenv global but not ruby
  • Swarm container not getting started with created overlay network
  • Get file from private repo into dockerfile
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.