Bundler fails in Docker mirror service with local gem paths
I’m using a
docker-compose.yml file that looks like.
version: '2' services: myapp: tty: true image: ruby:2.4 ports: - 3000:3000 volumes: - .:/app env_file: - .env sidekiq: build: . command: bundle exec sidekiq
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.
Adding this to
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.