Topic: Deploy to Your Production Host with Capistrano

Topic type:

Optional, but recommended best practice for Kete applications. After setting up your production host to be ready to be deployed to, the steps necessary to use Capistrano to deploy to your production host.

Originally written by Walter McGinnis, Kete Project Lead for Katipo Communications, Ltd.

Part of the Installation Guide


This step assumes you have done all previous steps to prepare your production host, or "target" in Capistrano lingo. You might also want to check out capify.org for reference, specifically Getting Started: Rails. There is also a wiki that may be useful as a reference.

One key thing to remember, it's the point of Capistrano really, is that you are running all the commands in your_app directory on your development machine, unless otherwise noted.

But enough reading, let's get to it.

First up, capify your app. This usually means running one command, then editing the resulting deploy.rb file to point at your svn repository, production host, etc. However, Kete includes a partially preconfigured Capistrano 2 Capfile and config/deploy.rb to simplify the process. You will still need to edit config/deploy.rb with a text editor and change the following settings to make sense for you:

:application # i.e. your_app, corresponds to directory name you are deploying from
:repository # this is your project subversion repository, i.e. ssh://your_git_host/your_path_to_your_repository/your_app.git
role :app # your host address, ip or domain role :web # same if you are deploying to only one host as i assume you are role :db # same if you are deploying to only one host as i assume you are :mongrel_servers # this is how many mongrel instances in your mongrel cluster, see note below about nginx and mongrel

Important Note: remember to match your mongrel settings in deploy.rb to what you have set up in your Nginx conf file!

Also note that for ssh you will probably want to set up ssh key in the repository host's user account. So you'll need to do a keygen on your target and copy that to your repository user's .ssh/authorized_keys for your target host and user.

Because our target hasn't been deployed to before, we have a few extra steps than normal to get our environment on that machine setup, but these are all wrapped up in one command (although it may take quite awhile):

You'll want to commit your config/deploy.rb to version control, then your ready to deploy:

$ git add config/deploy.rb
$ git commit -m "adding our project's specific deployment configuration details"
$ git push origin master
$ cap deploy:first_time

From now on (there are exceptions, for example if you have to install new gems or editing your mongrel settings), you just do the following to update your target (from your_app directory on your development machine):

$ cap deploy:update

You are now ready to visit your new site! Proceed to Configuration.

Discuss This Topic

There are 2 comments in this discussion.

Read and join this discussion

join this discussion

Creative Commons Attribution-Share Alike 3.0 New Zealand License
Deploy to Your Production Host with Capistrano by Walter McGinnis is licensed under a Creative Commons Attribution-Share Alike 3.0 New Zealand License