Home > Blockchain >  Issue with falcon web server when running containerized
Issue with falcon web server when running containerized

Time:12-06

I tried to use falcon within a container built from this Dockerfile:

FROM docker.io/library/ruby:3.1.2 AS build-stage

COPY Gemfile .
COPY Gemfile.lock .

RUN bundle install 

WORKDIR /app

COPY . .

CMD falcon host

My falcon.rb looks as follows

#!/usr/bin/env -S falcon host
# frozen_string_literal: true

load :rack, :supervisor

rack 'localhost' do
    endpoint Async::HTTP::Endpoint
        .parse('http://0.0.0.0:3001')
end

supervisor

But when I try to launch this container I get the following error message:

{"time":"2022-12-02T14:29:44 00:00","severity":"info","class":"Falcon::Command::Host","oid":2680,"pid":2,"subject":"Falcon::Command::Host","message":"Falcon Host v0.42.3 taking flight!\n- Configuration: falcon.rb\n- To terminate: Ctrl-C or kill 2\n- To reload: kill -HUP 2\n"}
/usr/local/bundle/gems/falcon-0.42.3/lib/falcon/service/supervisor.rb:23:in `require': cannot load such file -- process/metrics (LoadError)
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/service/supervisor.rb:23:in `<top (required)>'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/environments/supervisor.rb:23:in `require_relative'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/environments/supervisor.rb:23:in `block in load'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:134:in `instance_eval'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:134:in `block in load'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:127:in `each'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:127:in `load'
        from /app/falcon.rb:4:in `load_file'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:118:in `instance_eval'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:118:in `load_file'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:85:in `load_file'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:54:in `block in configuration'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:52:in `each'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:52:in `configuration'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/controller/host.rb:39:in `initialize'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:62:in `new'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:62:in `controller'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:84:in `call'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/top.rb:105:in `call'
        from /usr/local/bundle/gems/samovar-2.1.4/lib/samovar/command.rb:36:in `call'
        from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command.rb:30:in `call'
        from /usr/local/bundle/gems/falcon-0.42.3/bin/falcon:26:in `<top (required)>'
        from /usr/local/bundle/bin/falcon:25:in `load'
        from /usr/local/bundle/bin/falcon:25:in `<main>'

Interestingly everything works fine when running natively, but it seems when run inside a container there is an issue with the process/metrics dependency but I'm not sure how to resolve it.

CodePudding user response:

As pointed out by @anothermh in the comments the solution was to use the bundler for running falcon in the Dockerfile:

CMD bundle exec falcon host
  • Related