Rodrigo Rosenfeld Rosas

Installing Gitorious has never been so easy

Sun, 06 Mar 2011 20:40:00 +0000 (Updated at Sat, 07 May 2011 20:00:00 +0000)

Important update (May 07, 2011)

This article explains how to install Gitorious using RVM Ruby on Nginx + Passenger. I've recently created another cookbook for installing Gitorious on a recent Debian using native Ruby as well as Apache2 and using Exim as a smarthost for sending e-mail, which means that Gitorious won't block waiting the SMTP server for replying (specially if internet or the mail server is down). Also, this new cookbook will install much faster (less than 15 minutes in my PC). Feel free to continue reading this article if you want Gitorious with RVM Ruby. Otherwise, I would recommend the new cookbook.

Note: if you just want to install Gitorious, feel free to jump to Installing Gitorious section.

Installing Gitorious is HARD

Installing Gitorious is one of the most time-consuming servers to set-up I've seen. And I'm a Rails developer.

Installing the Rails application itself was not trivial as it should in the first time I set up a Gitorious server, some years ago. The usual "rake gems:install" procedure of the Rails 2 era didn't work and we had to follow the instructions, often outdated, of which gems we should install manually with all the problems it brings as version compatibility issues. Fortunately, the Ruby community brought Bundler some time ago which changed this painful process completely making it a breeze to manage Ruby project dependencies.

The good news is that Gitorious recently started to use bundler for managing its dependencies. So, installing the Rails application became trivial. But setting the web application itself was never the most time consuming task. Far from it. The Gitorious overall system uses a mixin of technologies including the web server, memcached for dealing with cache, a stomp server, like ActiveMQ, for managing queues of jobs like creating or cloning repositories, Sphinx for searching in the projects and repositories, a MySQL database for storing data, an HTTP server like Apache or Nginx plus Passenger, several custom services for serving the Git protocol with some changes from the original "git daemon", etc. Additionally, there are lots of configurations for e-mail delivery, SSH and the web application itself.

Some impatient people or with not enough skill often gave up on setting up a private Gitorious server for their companies. Others will successfully set-up after a whole day or two. If you're feeling adventurous or are just curious about how Gitorious work, try to follow these instructions or read the documentation present on Gitorious mainline repository.

This is no more true - Chef to the rescue

Well, I didn't mind very much that setting up a Gitorious was a hard task since I just needed to set it up once some years ago and another time when another developers team asked me about an year later. It is working great for us for a long time.

These days I decided that I should finally play a bit with Chef, a configuration management system. Nothing better than a real complex case to learn a new tool. Than I chose Gitorious for learning Chef. After 2 days (about 4hs/day) learning about Chef and writing the Gitorious cookbook, I found that Fletcher Nichol already had written one. I threw away almost all I had already done and continued from his work, since it didn't work on a fresh Debian 6.0 (Squeeze) system.

The result is a really easy process to install Gitorious on a fresh Debian system.

Installing Gitorious

If something documented here goes wrong, go bug Fletcher Nichol, since he is the original author of the Chef cookbooks ;) Just kidding! He did an awesome work, but feel free to post me a message if you have any issues.

These instructions are known to work on a Debian Squeeze 6.0 Linux distribution with only the base system checked to install on package selection. You can install it with VirtualBox, for instance, using the "netinst" CD image, which can be downloaded here or from some mirror near you. You'll need at least 1GB of virtual memory (I would suggest 512MB of physical memory plus 512MB of swap for a local testing only environment) and 4GB of hard-disk (maybe 3GB will be enough). I recommend you to use LVM since it is easier to expand your partitions if you need later. You can use a single partition if you prefer. If you are using VirtualBox, you'll probably like to set the network to bridge mode so that you can connect to your VM from your host machine. When asked for the machine name, if you don't have a fully qualified domain name (FQDN), you can use "gitorious.local".

Don't create a "git" user, since Chef will already create it correctly for you. If you need help creating the bridge network on Debian, check out these instructions.

With the fresh Debian system installed, logged as root:

echo 'deb squeeze main' > /etc/apt/sources.list.d/opscode.list
wget -qO - | apt-key add -
apt-get update
apt-get install chef git
wget -O /etc/chef/solo.rb
mkdir /root/chef-solo
wget -O /root/chef-solo/node.json

Change your /root/chef-solo/node.json to reflect your Gitorious settings, like SMTP server, etc. The downloaded node.json will download Gitorious from my fork, which includes a tree source view to Gitorious (see Merge Request #2220), as you can see in the picture below. Feel free to remove the "git" parameter from the "gitorious" entry and it will use the vanilla Gitorious repository. Also note that "locale" is set to "pt-BR". Change it to "en" or choose one of "pt-BR", "es" or "fr". I can tell you "en" and "pt-BR" will work but I haven't tested the other ones. If you change the "web_server" attribute to "apache2", you'll be on your own and you'll probably have to tweak it yourself.

Gitorious snapshot with source tree view

The "run_list" only needs to contain "recipe[gitorious]". The other ones are optional.

After changing the settings to reflect your preferences proceed with Gitorious automated installation:

git clone git:// /root/chef-solo/cookbooks
cd /root/chef-solo/cookbooks
git submodule update --init

If you don't have a FQDN nor a local DNS server, you can add your machine IP to your /etc/hosts on your host system. You need to access Gitorious with the FQDN provided in /root/chef-solo/node.json, which defaults to "gitorious.local", or the web application won't work.

Following these instructions, I was able to install Debian in 10 minutes and Gitorious within an extra hour. The actual time will depend mainly on your internet speed as well as your CPU and how many cores you'll make available for your VM. Maybe it is a good idea to allocate more resources to your VM on the installation process and then you could reduce them. There are several techniques that could speed up this installation process, like doing some tasks in parallel, using multiple cores on the VMs, using Debian Ruby instead of RVM, replacing ActiveMQ with stompserver gem, among other things. But this is beyond the scope of this article. I guess installing gitorious on a real fast server with great band-width could take about 20 minutes using these instructions. But since this process is automated, you can use this installation time to learn how to become productive with Vim :)

Simple, right? Get in touch if you have any issues.

Good luck! ;)


Thanks go to many people who made this possible, including:

  • Fletcher Nichol who developed the original Gitorious, RVM and RVM_Passenger cookbooks;
  • Opscode and Chef community for making this automated stuff possible;
  • The Gitorious developers and contributers;
  • David Heinemeier Hansson (DHH) for creating the fabulous Rails framework and all other rails-core team members as well as its contributors;
  • Yehuda Katz and all Bundler developers;
  • Yukihiro Matsumoto (Matz) and all Ruby developers and contributors for the lovely programming language they created and maintain;
  • Wayne Seguin for the excelent RVM tool and all of its contributors;
  • The Debian community for the wonderful Linux distribution;
  • Sun (recently sold to Oracle) for the great VirtualBox for managing virtual machines and all its contributors;
  • The Phusion company for delivering Passenger, easing the deployment of Rails and Rack applications;
  • Linus Torvalds, of course, not only for having started the Linux kernel development, but specially for the development of the greatest version control system: Git. Thanks also goes to Junio Hamano and the other Git developers and contributors;

There are probably lots more to thank and it is impressive how much people and work were required before one could easily install Gitorious for her/his company intranet. :)

comments powered byDisqus