如何捆绑安装本地pathgem与docker?

我正在使用docker和导轨。

我创build了一个本地的gem,并把它放到供应商/gem文件夹。

我将它添加到我的Gemfile中:

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

在我的Dockerfile中

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

运行docker-compose build ,显示:

 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 

在Dockerfile中添加这个之后,它就起作用了。

 ADD vendor/gems/my_gem /testapp/vendor/gems/my_gem 

您可以在Dockerfile中添加以下内容:

 RUN gem install --local path_to_gem/filename.gem