On IronWorker, how can I remote build all the gems in a Gemfile?

601 views Asked by At

Here is my Gemfile:

runtime 'ruby'
file 'Gemfile'
file 'config/database.yml', 'config/'                                                                                                                                         
file 'lib/models.rb', 'lib/'
remote_build_command 'bundle install --standalone'
exec 'my_worker.rb'

The remote_build_command, bundle install --standalone installs the gems, but they don't seem to load properly.

2

There are 2 answers

0
Travis Reeder On

bundle install --standalone installs the gems to bundle/bundler/setup directory. So at the top of my_worker.rb, add the following line:

require_relative 'bundle/bundler/setup'

This should load up all your gems.

0
Violet Shreve On

According to the documentation, you can now specify a gemfile in your worker file. I don't think this was available when this question was asked.

# example.worker

runtime "ruby"

gemfile "Gemfile"

file "lib/model.rb", "lib"

full_remote_build true

# You can also add gems individually if you don't want to use a separate file.
gem "pg"
gem "aws-sdk"

Instead of having a remote_build_command, you specify full_remote_build true, or just remote to have IronWorker set up your environment for you.