[chef] Re: Rails Recommendations


Chronological Thread 
  • From: Nathan L Smith < >
  • To:
  • Subject: [chef] Re: Rails Recommendations
  • Date: Mon, 1 Sep 2014 12:35:01 -0500




On Mon, Sep 1, 2014 at 1:12 AM, Angus Buchanan < " target="_blank"> > wrote:
I'm a sysadmin that comes from a Windows background, although I'm fairly comfortable with Linux, and LAMP stuff.  Now I need to deploy a simple rails application into a dev/test env and also into production.  It's  a very low load site, and it only needs to be available during office hours.  I'm imagining initially that it could run on a single machine, but splitting it out isn't a big deal later I guess.  I should point out that I'm ok at Ruby beyond Chef, but I'm not a web developer - I don't know much about Rails yet, and I've never written an Rails app before, so I'm new to the ecosystem.  The app in question was written by a friend, and is for a charity, and I'm helping them out.  I'm not in any rush, but I'd like to know the best approach.

What I'd like to know is what the current recommended approach is to building a server to run and deploy Rails in production, on Linux.  Specifically:

1) I have seen the application and application_rails cookbooks used - this seems to take a capistrano-like approach and implement it in Chef.  I'm ok with this, but I think that I might prefer to deploy it with capistrano or mina instead.  Is the application cookbook approach recommended?

Capistrano uses only a "push" model of deployment, where you type a command to deploy. When you deploy with Chef it's usually more of a "pull" model, where the chef-client runs ensure your application is running the revision that you tell it to. Both the application_rails cookbook and the deploy_revision built-in resource model their directory structures and callbacks based on how capistrano works, where the "current" directory is linked to a specific release.
 

2) An alternative approach that I'm interested in is using Omnibus to build a package that contains everything I need for the application to run, and the application itself.  If this were the case would I deploy the app using Chef's file or package resource, as cap or mina wouldn't be used? I think this might solve the following question...

That's also a good model, though you need to build a new package every time you deploy. If you have automated builds and Git caching with Omnibus this isn't so bad, but there is some overhead compared to just pulling down the latest release of your app from a Git repository.


3) What's the recommended way to get Ruby on the system?  I am not very keen on the idea of using rvm on servers, but system packages tend to lag too.  What is recommended?

If you're running on Ubuntu, this cookbook https://github.com/Sutto/chef-brightbox uses Brightbox's apt repo (https://launchpad.net/~brightbox/+archive/ubuntu/ruby-ng-experimental) and has pre-built packages for the latest Ruby and includes some other nice packages.

There are a few places with RPM specs for building Ruby on CentOS/Red Hat.

https://github.com/danielsdeleo/omnibus-rubies has omnibus definitions for building Rubies.


4) What's the recommended way to actually serve the app?  I've read about Apache and Passenger - this seems like a straightforward approach, and simpler than unicorn or puma and so on.  Are there good community cookbooks that can help here?

Either one will work fine, I prefer Unicorn+Nginx.
 

5) What about database stuff?  I see there's a database cookbook with some powerful tools, and a mysql cookbook, but should I try to seed the database with Chef or do that manually?

The deploy_revision resource (https://docs.getchef.com/chef/resources.html#deploy) with the default settings will run the migrations for you. The community database cookbook have some good resources for creating databases and users.
 

I think that's all my questions for now... thanks in advance for your guidance.

-aob



--



Archive powered by MHonArc 2.6.16.

§