Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bundle install a local path gem with docker?

I am using docker and rails.

I created a local gem and put it into vendor/gems folder.

And I add this into my Gemfile:

gem 'my_gem', path: './vendor/gems/my_gem'

In my Dockerfile

RUN mkdir /testapp
WORKDIR /testapp
ADD Gemfile /testapp/Gemfile
ADD Gemfile.lock /testapp/Gemfile.lock
RUN bundle install
ADD . /testapp

After run docker-compose build, it shows:

The path `/testapp/vendor/gems/my_gem` does not exist.
ERROR: Service 'web' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 13
like image 979
scho Avatar asked Nov 06 '15 05:11

scho


People also ask

How do I install bundles to install missing gems?

In the invoked popup, start typing bundler, select bundle install and press Enter . Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .

Can I install packages in Docker container?

To install packages in a docker container, the packages should be defined in the Dockerfile. If you want to install packages in the Container, use the RUN statement followed by exact download command . You can update the Dockerfile with latest list of packages at anytime and build again to create new image out of it.

How do I install a gem file?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.

What is a Docker bundle?

A Dockerfile can be built into an image, and containers can be created from that image. Similarly, a docker-compose. yml can be built into a distributed application bundle(DAB), and stacks can be created from that bundle. In that sense, the bundle is a multi-services distributable image format.


2 Answers

After I add this in Dockerfile, it worked.

ADD vendor/gems/my_gem /testapp/vendor/gems/my_gem
like image 136
scho Avatar answered Oct 26 '22 03:10

scho


You can add following at your Dockerfile:

RUN gem install --local path_to_gem/filename.gem
like image 31
sadaf2605 Avatar answered Oct 26 '22 04:10

sadaf2605