Cannot install gems from git in dockerized rails app
docker, ruby-on-rails
Solution
It seems you don't have git inside the container. To install it on an Alpine image, you should add to your Dockerfile this:
FROM ruby:2.4-alpine
RUN apk update && apk add git
... the rest of your Dockerfile ...
Hope it helps.
Problem
Please, help me with building my first docker image. My `Gemfile` contails: ``` gem 'webpacker', github: 'rails/webpacker' ``` Here is `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 and docker-compose: ``` Docker version 17.03.1-ce, build c6d412e docker-compose version 1.13.0, build 1719ceb ``` When I run ``` docker build . ``` I receive 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 guess, the reason is related with github source, because if I remove all gems with github source from Gemfile, then gems will be fetched correctly from rubygems repository Upd: when I use `ruby:2.4-slim` instead of `alpine` linux as base image, then build completes without errors