Private gems are not docker mounted

I am trying to run a rails application with docker. There are several gems that are installed using the ssh url github, which are as follows:

Gemfile

gem 'swagger-docs', :git => 'git@github.com:xyz/swagger-docs.git', :branch => 'my_branch'

I added keysin the docker, which is able to clone the required repo and install git gems.

Dockerfile

RUN mkdir -p /root/.ssh
COPY ./id_rsa /root/.ssh/id_rsa

RUN chmod 700 /root/.ssh/id_rsa

RUN ssh-keygen -f /root/.ssh/id_rsa -y > /root/.ssh/id_rsa.pub

RUN ssh-keyscan github.com >> /root/.ssh/known_hosts

When I create it (including bundle install), everything goes well and the image is successfully created. But when I run docker-compose up, it gives the following error

/usr/local/bundle/gems/bundler-1.9.2/lib/bundler/source/git/git_proxy.rb:155:in `allowed_in_path': The git source git@github.com:xyz/swagger-docs.git is not yet checked out. Please run `bundle install` before trying to start your application (Bundler::GitError)
+4
source share
1 answer

Try replacing git with https in your Gemfile, i.e.

  gem 'swagger-docs', git: 'https://github.com:xyz/swagger-docs.git', branch: 'my_branch'

... Docker :

  RUN git config --global url."https://".insteadOf git://

, bundle install, ..

  ...
  RUN gem install bundler && bundle install

  CMD bundle install && rails s -p 3000 -b 0.0.0.0
0

All Articles