Sunday, April 3, 2011

Server setup for Rails Camp NZ

This is a bit of a dump of the stuff we needed to set up the server and network for Rails Camp NZ. Hopefully it will be of use to others trying to run similar events.

Taking over the DNS for the network with Dnsmasq

The first and most important part of setting up the server for Rails Camp is making it serve custom DNS records that let you create seamless copies of websites that rubyists needs access to.


  • Set your router(we used an airport extreme) to point to the server you're going to be using. The server should have a static IP outside the DHCP range being issued.  
  • Setup DNSmasq on the server, this requires telling it IP's for various things. There's a copy of the setup we used which assumes the server has an IP of 10.0.1.201 at https://gist.github.com/901075. We created this by taking Ben Hosking's Babushka recipes and changing values until it worked.
  • Setup up a web server(we used apache) with its default site serving whatever page you want everyone to see first.
  • Serve Rails apps like twetter in the normal way with addresses pointing at the appropriate hosts.

Creating a Rubygems Mirror

Gem Mirror used to be  a built in gem command, but it was extracted out into it's own repo due to how rarely it was used. Unfortunately this means it's less well maintained that it once was and a bit more of a pain to set up.

The gem server will need a decent amount of RAM, more than 2 GB and at least 33 GB of free space to fit all the gems(this amount is growing all the time as more gems are created). We learned about the RAM requirement the hard way as the initial laptop I tried to use failed to index the gems when it ran out of memory while indexing them.

  • Mirror all the gems using rubygems-mirror. I've updated the documentation for this and fixed a bug in the code but I'm waiting for that to be merged in, if it doesn't happen then there are better docs at my fork
  • Once the mirror has finished downloading, run gem generate_index in the folder you sent the gems to(This is where everything will blow up if you don't have enough RAM).
  • Finally, point rubygems.org in your server at the directory you generated the index in.
  • (optionally) Update your server conf so that it will send not-modified messages when people request the gem index, otherwise it'll be sent every time someone does a bundle install.
Git


There are various levels of complexity for git setup depending on whether you want to give people write access and how much time you want to spend managing keys.

The simple stopgap is to put all your git repos you want shared in a directory and run:
git daemon --base-path=dir --export-all
Which will cause all the repos under dir to be served by the git daemon, unfortunately this is read only.

To get write access users will need to use ssh and have their keys added to authorised_keys for a user on the server. You can do this manually or with something like gitosis. We didn't get as far as gitosis for Rails Camp NZ, but I'll look at doing it next time.

Things to do Next Time

  • Better git access
  • Wiki
  • Host Ruby versions for rvm
  • Ubuntu package mirror