Aje*_*han 6 ruby git ruby-on-rails docker docker-compose
我正在尝试使用docker运行Rails应用程序。github的ssh url安装的gem如下:
宝石文件
gem 'swagger-docs', :git => 'git@github.com:xyz/swagger-docs.git', :branch => 'my_branch'
Run Code Online (Sandbox Code Playgroud)
我添加了keysdocker中的in,它能够克隆所需的repo并从git安装gem。
Docker文件
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
Run Code Online (Sandbox Code Playgroud)
当我构建它(包括bundle install)时,一切顺利,并且图像成功构建。但是当我运行时docker-compose up,它给出以下错误
/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)
Run Code Online (Sandbox Code Playgroud)
尝试在 Gemfile 中将 git 替换为 https,即
gem 'swagger-docs', git: 'https://github.com:xyz/swagger-docs.git', branch: 'my_branch'
Run Code Online (Sandbox Code Playgroud)
...或者在运行捆绑安装之前将其添加到您的 Dockerfile 中:
RUN git config --global url."https://".insteadOf git://
Run Code Online (Sandbox Code Playgroud)
如果没有任何效果,那么只需运行bundle install两次,即
...
RUN gem install bundler && bundle install
CMD bundle install && rails s -p 3000 -b 0.0.0.0
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
985 次 |
| 最近记录: |