How to require dependencies for ruby IronWorker

62 views Asked by At

I put together a simple script to run in iron.io. I follow the steps in this tutorial but fail during testing.

$ docker run --rm -it -e "SLACK_API_TOKEN="xox-LALLALA"" -v "$PWD":/worker -w /worker iron/ruby ruby bubbebot.rb
bubbebot.rb:1:in `require_relative': cannot load such file -- /worker/slack-ruby-client (LoadError)
    from bubbebot.rb:1:in `<main>'

It's failing whether I try require or relative_require. Any idea what I need to do to vendor this dependency?

1

There are 1 answers

1
John Paul On BEST ANSWER

That error message means you are trying to use something that is not in the iron/ruby image.

To understand how to fix this, let's take a look at the Dockerfile for that image:

FROM iron/base RUN apk update && apk upgrade \ && apk add libxml2 libxslt libevent libffi glib ncurses readline \ openssl yaml zlib curl mariadb-libs libpq ruby ruby-io-console \ ruby-bigdecimal \ && rm -rf /var/cache/apk/*

If you want to use something that is not present on that build, you'll need to add it yourself. I would suggest making your own custom Docker image. Something along the lines of this should work: FROM iron/ruby:2.3.1-dev RUN apk add && apk update RUN gem install slack --no-ri --no-rdoc RUN rm -rf /var/cache/apk/*

Build that image and push it to Dockerhub and try running your code on that.