Reputation: 233
I have been trying to create a docker image and run the ruby files
Following is the code for creating the docker image
FROM ruby:3
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && \
bundle config --global frozen 1 && \
bundle install
RUN gem install extensions
COPY app.rb config.ru database.rb utils.rb thin.rb ./
EXPOSE 8080
CMD exec thin -R config.ru -p 8080 start
I also tried CMD bundle exec thin start
instead of last command above.
I then execute the following command to build the image
sudo docker build -t project3 .
And the build is successful.
But when I run docker run -p 8080:8080 project3
I receive the following error
mayuresh@mayuresh-Lenovo-ideapad-330-15IKB:~/Softwares/CS291_project3$ sudo docker run -p 8080:8080 project3
/usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/regular.rb:22:in `initialize': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/pattern.rb:59:in `new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/pattern.rb:59:in `block in new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/equality_map.rb:43:in `fetch'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/pattern.rb:59:in `new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:67:in `new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:70:in `block in new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:70:in `map'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:70:in `new'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/base.rb:1641:in `compile'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/base.rb:1629:in `compile!'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/base.rb:1271:in `error'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/base.rb:1831:in `<class:Base>'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/base.rb:889:in `<module:Sinatra>'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/base.rb:22:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/main.rb:26:in `<module:Sinatra>'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra/main.rb:1:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /usr/local/bundle/gems/sinatra-2.0.7/lib/sinatra.rb:1:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
from /app/app.rb:1:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from config.ru:1:in `block in <main>'
from /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /usr/local/bundle/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in `eval'
from /usr/local/bundle/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in `load'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/controllers/controller.rb:72:in `start'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/runner.rb:203:in `run_command'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/runner.rb:159:in `run!'
from /usr/local/bundle/gems/thin-1.7.2/bin/thin:6:in `<top (required)>'
from /usr/local/bundle/bin/thin:23:in `load'
from /usr/local/bundle/bin/thin:23:in `<main>'
<internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sinatra (LoadError)
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /app/app.rb:1:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from config.ru:1:in `block in <main>'
from /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /usr/local/bundle/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in `eval'
from /usr/local/bundle/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in `load'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/controllers/controller.rb:72:in `start'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/runner.rb:203:in `run_command'
from /usr/local/bundle/gems/thin-1.7.2/lib/thin/runner.rb:159:in `run!'
from /usr/local/bundle/gems/thin-1.7.2/bin/thin:6:in `<top (required)>'
from /usr/local/bundle/bin/thin:23:in `load'
from /usr/local/bundle/bin/thin:23:in `<main>'
I tried implementing the code mentioned on Link1 Link2
Also, I would like to mention that earlier I have dockerized many projects with similar docker file, but I don't understand what could be the problem associated in this approach.
Thanks for help!
Upvotes: 0
Views: 1265
Reputation: 28305
The release history for mustermann
says that support for ruby v3.0.0
was added in v1.1.0
.
You are using ruby v3.0.0
with mustermann v1.0.3
.
Either downgrade ruby to 2.7, or upgrade mustermann to 1.1.0+
Upvotes: 1