turnbullpress / dockerbook-code

The code and configuration examples from The Docker Book (http://www.dockerbook.com)
927 stars 581 forks source link

Sinatra version issue #79

Open yeoleobun opened 1 year ago

yeoleobun commented 1 year ago

The code at https://github.com/turnbullpress/dockerbook-code/blob/master/code/5/sinatra/webapp/Dockerfile#L6 and https://github.com/turnbullpress/dockerbook-code/blob/master/code/5/sinatra/webapp_redis/Dockerfile#L6 can't progress.

#6 1.939 ERROR:  Error installing sinatra:                                      
#6 1.939        There are no versions of mustermann (~> 3.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?                                                                         
#6 1.939    mustermann requires Ruby version >= 2.6.0. The current ruby version is 2.5.0.

According https://github.com/sinatra/sinatra/blob/master/README.md?plain=1#L2828

Versions of Ruby before 2.6 are no longer supported as of Sinatra 3.0.0.

But the version of ruby on apt is 2.5.0, and sinatra version on gem is 3.0.2, so it's a conflict.

It's better to give a specific version to sinatra. (2.2.2 was latest supporting Ruby 2.5)

Break00 commented 1 year ago

it works!!!

FROM ubuntu:18.04

RUN apt-get -qq update && apt-get -qq install ruby ruby-dev build-essential redis-tools
RUN gem install --no-rdoc --no-ri json redis
RUN gem install --no-rdoc --no-ri sinatra -v 2.2.2

RUN mkdir -p /opt/webapp

EXPOSE 4567

CMD [ "sh", "-c", "ruby /opt/webapp/bin/webapp" ]