[Ruby] Errors when starting container made with Pack
almonk opened this issue · 4 comments
almonk commented
Trying to pack build
the ruby example in this repo and I get the following errors when trying to run it with docker run --rm -p 8080:8080 ruby-sample
:
bundler: failed to load command: rackup (/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/bin/rackup)
OptionParser::MissingArgument: missing argument: -p
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:97:in `parse!'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:333:in `parse_options'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:195:in `initialize'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:148:in `new'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:148:in `start'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/bin/rackup:4:in `<top (required)>'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/bin/rackup:23:in `load'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/bin/rackup:23:in `<top (required)>'
jromero commented
Verified that this issue exists with the heroku builder:
┌─[javier.romero][Javiers-MacBook-Pro][±][master {1} U:1 ✗][~/dev/samples]
└─▪ pack build my-app --builder heroku/buildpacks:18 -p apps/ruby-bundler/
...
Status: Downloaded newer image for heroku/pack:18
===> DETECTING
[detector] heroku/ruby 0.0.1
[detector] heroku/procfile 0.3
===> RESTORING
[restorer] Cache '/cache': metadata not found, nothing to restore
===> ANALYZING
[analyzer] Warning: Image 'index.docker.io/library/my-app:latest' not found
===> BUILDING
[builder] -----> Compiling Ruby/Rack
[builder] -----> Using Ruby version: ruby-2.5.5
[builder] -----> Loading Bundler Cache
[builder] -----> Installing dependencies using bundler 2.0.1
[builder] Running: bundle install --without development:test --path /layers/heroku_ruby/gems/vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
[builder] Warning: the running version of Bundler (2.0.1) is older than the version that created the lockfile (2.0.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
[builder] Fetching gem metadata from https://rubygems.org/.............
[builder] Using bundler 2.0.1
[builder] Fetching mustermann 1.0.3
[builder] Fetching rack 2.0.7
[builder] Fetching tilt 2.0.9
[builder] Installing mustermann 1.0.3
[builder] Installing rack 2.0.7
[builder] Installing tilt 2.0.9
[builder] Fetching rack-protection 2.0.7
[builder] Installing rack-protection 2.0.7
[builder] Fetching sinatra 2.0.7
[builder] Installing sinatra 2.0.7
[builder] Bundle complete! 1 Gemfile dependency, 6 gems now installed.
[builder] Gems in the groups development and test were not installed.
[builder] Bundled gems are installed into `/layers/heroku_ruby/gems/vendor/bundle`
[builder] Bundle completed (11.36s)
[builder] Cleaning up the bundler cache.
[builder] -----> Detecting rake tasks
[builder]
[builder] ###### WARNING:
[builder]
[builder] You have not declared a Ruby version in your Gemfile.
[builder] To set your Ruby version add this line to your Gemfile:
[builder] ruby '2.5.5'
[builder] # See https://devcenter.heroku.com/articles/ruby-versions for more information.
[builder]
[builder]
[builder] -----> Discovering process types
[builder] Procfile declares types -> (none)
===> EXPORTING
[exporter] Adding layer 'app'
[exporter] Adding layer 'config'
[exporter] Adding layer 'launcher'
[exporter] Adding layer 'heroku/ruby:env'
[exporter] Adding layer 'heroku/ruby:gems'
[exporter] Adding layer 'heroku/ruby:ruby'
[exporter] *** Images (49abbb8c9fe5):
[exporter] index.docker.io/library/my-app:latest
===> CACHING
[cacher] Caching layer 'heroku/ruby:gems'
Successfully built image my-app
┌─[javier.romero][Javiers-MacBook-Pro][±][master {1} U:1 ✗][~/dev/samples]
└─▪ docker run --rm -it -p 8080:8080 my-app
bundler: failed to load command: rackup (/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/bin/rackup)
OptionParser::MissingArgument: missing argument: -p
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:97:in `parse!'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:333:in `parse_options'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:195:in `initialize'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:148:in `new'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/lib/rack/server.rb:148:in `start'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/bin/rackup:4:in `<top (required)>'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/bin/rackup:23:in `load'
/layers/heroku_ruby/gems/vendor/bundle/ruby/2.5.0/bin/rackup:23:in `<top (required)>'
almonk commented
I realised through some trial and error that this issue is resolved by adding a Procfile
with the contents:
web: ruby app.rb
I can make a pull request to add this fix
jkutner commented
The error was cause by a missing PORT
environment variable. The default process type generated by the Ruby buildpack has -p $PORT
in the command. If adding a Procfile
doesn't work, then one can also run the image with docker run -e PORT=8080
or similar.
zmackie commented
This seems resolved. Gonna close for now.