Welcome Guest | Login

How to Deploy Rails Using Git with Capistrano on Mongrel with HostingRails



This is a wiki article created by HostingRails users. Please login or signup to make edits.


  This tutorial assumes you are a beginner that has a working Rails app on your local machine that you wish to deploy onto your HostingRails.com account. Note: During this guide, LOCAL refers to your local box (or development box) and SERVER refers to HostingRails. This tutorial does not go over setting up your rails application, only the git repository and configuration of your capfile.

Contents:
  1. Setting Up Git
  2. Setting Up Capistrano
  3. Basic Usage


Setting Up Git
Back to top

SERVER
Setup a directory to house your git repository.
$ mkdir ~/git
LOCAL
Get your rails app to the /git directory we just created.
$ scp /path/to/<zipped_app>.zip <username>@<domain>:~/git/
SERVER
Ready your git directory.
$ cd git/
$ unzip <zippedapp>.zip
$ cd <appname>
If you want to setup .gitignore, do so now (but you can always do it later if you want).
$ vi .gitignore
Possible lines to add to your .gitignore
.DS_Store
log/*.log
tmp/**/*
db/*.sqlite3
Now we turn the /git directory into a git repository
$ git init
$ git add .
$ git commit -a -m "Initial commit."
Tada! Your git repository is all setup. Let's get it ready for automated deployment!



Setting Up Capistrano
Back to top

LOCAL
Clone a copy of your git repository to your development box and capify it.
$ git clone <username>@<domain>:/home/<username>/git/<appname> /path/to/<appname> # note: the <appname> folder does not exist yet
$ cd /path/to/<appname>
$ capify .
You must now properly configure Capistrano to use your git repository. Here is a quick example of what you can edit in your deploy.rb file to set this up:
set :repository,  "#{user}@#{domain}:/home/#{user}/git/#{application}"
set :scm, :git
set :scm_username, user
set :runner, user
set :use_sudo, false
set :branch, "master"
set :deploy_via, :checkout
set :git_shallow_clone, 1
set :deploy_to, "/home/#{user}/apps/#{application}"
default_run_options[:pty] = true
Add/commit/push your changes and then do your initial deployment process.
$ git add .
$ git commit -a -m "Capified."
$ git push
$ cap deploy:setup
$ cap deploy:cold
You're all set for some Capistrano deployment with the greatest version control there is, git!



Basic Usage
Back to top

The most basic scenario for your usage will look like this:
$ git add .
$ git commit -a -m "Change comments..."
$ git push
$ cap deploy
Of course you can use branches, tags, and do a whole lot more of great things--but that's for another tutorial. Enjoy the git'n!



Hello Guest! In order to edit this article you must be an active client with us, please log in or sign up today!






Contributing Author(s):
Scott
Kotrin