Rails Continuous Deployment

Hi all,

I've successfully built a personal project using Rails (I come from
the .NET world), and I'm now looking into deployment. Here's what I
want to do:

- Store my application in source control (Subversion)
- Whenever I checkin, kick off a continuous build and deployment
process (on the build machine) that will:
  - Deploy the MySQL database to the web server (myapp_testing)
  - Copy the ruby application files to a virtual directory
(test.myapp.com) so that I can view it online

In the .NET world I would have done this using CruiseControl.NET and
NAnt, running OSQL.exe to deploy the database from a .SQL script file.
Is the process similar for a Rails application, or is there a much
more "rails-y" way to do it?

I notice that the database.yml files point to dev, test and production
databases. But where do you tell the application whether to use
production/test or not?

Also, how do you handle changes between schema versions and deploying
them?

Any ideas would be appreciated - I can always do it the .NET way but
I'd prefer to use a more standard way if I can.

Paul

You could check out CruiseControl.rb ( http://
cruisecontrolrb.thoughtworks.com/ ). You could also look into
Capistrano ( www.capify.org )

There is a method to change which environment.

Cheers,
Zach Inglis

→ Blog -- http://www.zachinglis.com
→ Company -- http://www.lt3media.com
→ Portfolio -- http://portfolio.zachinglis.com

Rails uses a system called migrations for database schema management.
Each migration (just a ruby file) has a script that can update the
schema from the prior to the next version or the reverse. You can
then use the db:migrate rake task to migrate a database from one
version to another or to the latest version. These files are stored
in CM just like other source files. There are several continuos
integration frameworks that do the auto-build after a check-in. There
may also be a CruiseControl version for Rails. SVN seems to be the
predominant CM tool used with Rails, and MySQL is well supported as
well.

Michael

Check out Rubyology's podcast #5 (http://rubyology.com/podcasts/show/
11) for Rails deployment strategies and tips on Subversion,
Capistrano, and Secure Shell

Regards,
Chris Matthieu
http://www.rubyology.com

Thanks guys,

I ended up going with CruiseControl.NET (since I am already using it for other projects - it’s nice to see them all from the one panel) but using custom rake tasks to do the deployment and configuration.

The issue I’m having now is with deployment. I tried a heap of methods on Apache as well as IIS (all on Windows 2003) but couldn’t get any of them working. What kind of server is every body using? The nightmare of deploying a rails app has really gotten me down :frowning:

Cheers,

Paul

Paul Stovell wrote:

Thanks guys,

I ended up going with CruiseControl.NET (since I am already using it for other projects - it's nice to see them all from the one panel) but using custom rake tasks to do the deployment and configuration.

The issue I'm having now is with deployment. I tried a heap of methods on Apache as well as IIS (all on Windows 2003) but couldn't get any of them working. What kind of server is every body using? The nightmare of deploying a rails app has really gotten me down :frowning:

Apache + Mongrel. Helper tools: Mongrel Cluster and Capistrano. I used Coda Hales walkthrough to get started, it's a pretty good end to end description:

http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/

Notice, there's a rails-deployment group where all the experts are hanging out :wink:

Thanks Jacob, I’ll follow those instructions and stop spamming this list :slight_smile: