Bindle 2 is fresh out of the oven; one of the main areas of focus was making Bindles more intuitive to create & navigate—to that end we’re making use of a binary called Autotrace which helps us calculate the boundaries of items . Unfortunately there is no ruby interface for this library in rails just yet, so we needed to get a binary running on our Heroku Cedar instance. Luckily it was pretty easy to do.
Here’s how to use binaries with Rails on Heroku:
Running binaries on heroku is possible if they are in the
bin/ directory of your app. This is not officially supported, so use at your own risk. Heroku runs on Ubuntu 10.04 LTS 64bit, so you’ll want to download it to compile your program on a VM. Install Ubuntu as normal, then download the source code for the program you are interested in.
If your program doesn’t have any dependencies which aren’t already installed on ubuntu (or only depend on header files) you are probably good to go with the normal compilation process. If, like autotrace, it depends on libraries which don’t come installed on Ubuntu, then they won’t be on your Heroku instance, and you’ll need to compile a statically linked version.
Don’t worry, it’s not super difficult. Here’s what I did:
# download and unpack source into a directory and cd in there: cd autotrace-0.31.1/ # install ubuntu packages which the program requires sudo apt-get install libmagick++-dev # configure to be statically linked ./configure --enable-shared=no # compile make
make process creates an executable, which you can then place into the
bin/ directory of your heroku app. I put it in the
bin/x86_64-linux/ directory just to be clear about what can run where. Statically linked
autotrace comes in at around 400k, so in order to keep your slug size down you’ll probably want to use your discretion here.
Finally, to test, you can open up a heroku console (
heroku run console) and check that it is running successfully:
irb(main):006:0> `bin/x86_64-linux/autotrace` Usage: bin/x86_64-linux/autotrace [options] . (Missing .) For more information, use ``-help''.
- This makes dragging items more intuitive: click on the item to drag it, click on the negative space to pan. So no more rectangles to confine your images! [↩]