Docker web image does now work with rspec gem

  docker, rspec, ruby-on-rails

I’ll jump straight into the problem.
I have installed a rspec gem for testing(add rspec gem, then bundle install and rails g rspec:install). However when I run docker-compose up to run my app with docker a web image does not work. Here is a log message returned from that image:

web_1          | Could not find diff-lcs-1.4.4 in any of the sources
web_1          | Run `bundle install` to install missing gems.

My Dockerfile.web is defined bellow:

FROM ruby:2.6.5
ENV BUNDLER_VERSION=2.1.4
# Set Rails to run in production
ENV RAILS_ENV production
ENV RACK_ENV production

RUN apt-get update -qq && apt-get install -y nodejs postgresql-client libpq-dev yarn
RUN gem install bundler -v 2.1.4
RUN mkdir /my_app

WORKDIR /my_app
COPY Gemfile /my_app/Gemfile
COPY Gemfile.lock /my_app/Gemfile.lock
RUN bundle install --without development test
COPY . /my_app
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

# Start the main process.
RUN bundle exec rake SECRET_KEY_BASE=<token>  assets:precompile
CMD bundle exec puma -C config/puma.rb

Dockerfile:

FROM ruby:2.6.5
ENV BUNDLER_VERSION=2.1.4
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client libpq-dev
RUN gem install bundler -v 2.1.4
RUN mkdir /my_app
WORKDIR /my_app
COPY Gemfile /my_app/Gemfile
COPY Gemfile.lock /my_app/Gemfile.lock
RUN bundle install

COPY . /my_app
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
RUN bundle exec rake assets:precompile
CMD ["rails", "server", "-b", "0.0.0.0"]

I have diff-lcs gem installed so I don’t know why I get this error.If I remove rspec gem then all docker images work fine.
I would appreciate any help.
Thanks in advance.

Source: Docker Questions

LEAVE A COMMENT