Unable to install git gems in dockerized rails application

Please help me with creating my first docker image. My Gemfileworks:

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

Here Dockerfile:

FROM ruby:2.4-alpine

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

Docking dockers and dockers:

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

When i started

docker build .

I get errors:

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.

I think the reason is related to the github source, because if I remove all the gems using the github source from the Gemfile, then the stones will be correctly selected from the rubygems repository.

Update : When I use ruby:2.4-sliminstead of alpinelinux as a base image, then the assembly is completed without errors

+4
source share
1 answer

, git . , Dockerfile :

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

, .

+5

Source: https://habr.com/ru/post/1676503/


All Articles