by Jay Fajardo
We’ve recently moved most of our projects to Engine Yard because of its rails centric awesomeness.
While Proudcloud codes with Rails 3.0.0, Ruby 1.9.2RC and the latest builds of MongoDB/Mongoid, being on the edge does have its drawbacks when using hosting providers who need to play it safe with stable package releases.
When deploying Rails 3 Mongoid based apps on EY’s AppCloud, we discovered that;
- EY does not support MongoDB out of the box and requires custom chef recipes;
- You need to create a custom cluster of instances with MongoDB installed on a utility instance;
- EY’s latest installed binary of MongoDB version is 1.4.4 while Mongoid 2.beta.17 requires >= 1.6.0.
- There’s no documentation anywhere to help you with this issue.
Getting MongoDB on Engine Yard
As a backgrounder, Engine Yard has custom recipes that will allow you to install MongoDB (and other packages) on AppCloud. The recipes can be found on github, with specific instructions for MongoDB here.
Remember though to un-comment the reference to MongoDB in cookbooks/main/recipes/default.rb.
The ridiculously simple solution: Portage
Trying to make various Mongoid versions and dependencies play well with 1.4.4 and Rails 3.0.0 failed miserably. EY support suggested we tweak the emerge recipes to retrieve the desired build and have the package installed during the EY deploy.
Jason Torres, who has a black belt in rails app deployment, thought otherwise and discovered a simpler approach.
Going into your utility instance’s shell, you’ll find the various Gentoo Portage package definitions for MongoDB in /engineyard/portage/engineyard/dev-db/mongodb-bin/. We wanted the latest MongoDB build which was 1.6.2 at the time of this writing.
The trick is to have Portage retrieve the latest MongoDB build. To do this, Jason merely copied the .ebuild definition for the latest build to another file, making sure that the target filename included the desired build version number.
When you run the emerge command, Portage determines the build version from the filename. Given this, the next step would be to simply execute emerge on the .ebuild file with the –digest parameter. This would add it to the Portage tree.
The last step would be to restart MongoDB.
note If you had not yet installed any MongoDB version on your instance, you can start instead with the Portage steps (sans MongoDB restart) and then proceed to the instructions for custom recipes.
So go ahead and get rockin’ with the latest Mongodb+Mongoid on Engine Yard.