我正在尝试使用docker运行rails应用程序.很少有宝石由
github的ssh url安装,如下所示:
Gemfile
gem 'swagger-docs',:git => 'git@github.com:xyz/swagger-docs.git',:branch => 'my_branch'
我在docker中添加了键,它能够克隆所需的repo并从git安装gem.
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
当我构建它(包括捆绑安装)时,一切顺利,图像成功构建.但是当我运行docker-compose时,会出现以下错误
/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)
解决方法
尝试在Gemfile中用https替换git,即
gem 'swagger-docs',git: 'https://github.com:xyz/swagger-docs.git',branch: 'my_branch'
…或者在运行bundle install之前将其添加到Dockerfile中:
RUN git config --global url."https://".insteadOf git://
如果没有任何作用,那么只需运行两次捆绑安装,即
... RUN gem install bundler && bundle install CMD bundle install && rails s -p 3000 -b 0.0.0.0
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。