加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 无法在dockerized rails应用程序中安装git中的

发布时间:2020-12-17 03:33:11 所属栏目:百科 来源:网络整理
导读:请帮我构建我的第一个docker镜像. 我的Gemfile包含: gem 'webpacker',github: 'rails/webpacker' 这是Dockerfile: FROM ruby:2.4-alpine...ADD Gemfile $INSTALL_PATH/GemfileADD Gemfile.lock $INSTALL_PATH/Gemfile.lockRUN bundle installADD . $INSTAL
请帮我构建我的第一个docker镜像.
我的Gemfile包含:

gem 'webpacker',github: 'rails/webpacker'

这是Dockerfile:

FROM ruby:2.4-alpine

...
ADD Gemfile $INSTALL_PATH/Gemfile
ADD Gemfile.lock $INSTALL_PATH/Gemfile.lock
RUN bundle install
ADD . $INSTALL_PATH
...

Docker和docker-compose:

Docker version 17.03.1-ce,build c6d412e
docker-compose version 1.13.0,build 1719ceb

我跑的时候

docker build .

我收到错误:

Fetching https://github.com/rails/webpacker.git
sh: git: not found

Git error: command `git clone 'https://github.com/rails/webpacker.git'
"/usr/local/bundle/cache/bundler/git/webpacker-
61415c05b31197242a5fde705ba334f36321be12"
--bare --no-hardlinks --quiet` in directory /test_task has failed.

我猜,原因与github源有关,因为如果我从Gemfile中删除所有使用github源的gems,那么将从rubygems存储库中正确获取gems

更新:当我使用ruby:2.4-slim而不是alpine linux作为基本映像时,构建完成没有错误

解决方法

看来你的容器里面没有git.要在Alpine映像上安装它,您应该添加到Dockerfile:

FROM ruby:2.4-alpine
RUN apk update && apk add git
... the rest of your Dockerfile ...

希望能帮助到你.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读