English 中文(简体)
Packaging precompiled binaries inside of a gem
原标题:

I ve got a ruby web app that uses lilypond to generate sheet music based on user input. I d like to move the hosting to heroku (I ve recently used heroku on a few projects and really liked it, plus my traffic is low enough that it d be free host it on heroku, for a while at least). However, heroku s dyno architecture doesn t allow you to ssh in and install whatever packages you want...instead, you give it a gems manifest, and it will install the gems for you.

So, if I m going to deploy to heroku, I m going to need to package lilypond as a gem. I ve released a few pure-ruby gems, but haven t dealt with native extensions or precompiled binaries, or anything like that.

Is it possible to take some precompiled binaries and package it inside a gem? Ideally, this would include binaries for OS X (which I develop on) and debian linux (which is what s running on heroku), and would install the proper binary when the gem was installed.

问题回答

it is possible, since precompiled binary gems for windows are the norm. Take a look at rake compiler, perhaps. also https://github.com/rdp/ruby_tutorials_core/wiki/gem (https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems) might help -r

I think you ve got a few options here:

You could get the Lilypond source and package it into a gem with a native C extension. There are some useful guides on how to do that at http://guides.rubygems.org/c-extensions/ and http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions

There s also a gem called gitara but I haven t been able to find any information about using it on Heroku. It might be worth emailing the author and asking if he knows anything about that.

You could create a Heroku buildpack that installs Lilypond as part of your deployment. I wasn t able to find any for Lilypond, but there are plenty of examples that do similar things - for example, this one installs Imagemagick (which is included by default on Heroku, so probably not necessary anymore - but hopefully the code is helpful). More documentation at https://devcenter.heroku.com/articles/buildpack-api and https://devcenter.heroku.com/articles/buildpack-binaries

Based on my reading, I think the buildpack option is the best way to go.

Hopefully this helps!

Instead of precompiling, you should be able to just list the gem in your .gems file, see the Heroku documentation. Of course, this requires your gem builds the native code correctly - this is still a task, but hopefully an easier one.





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签