To setup development environment is not easy. Especially for server side, lots of dependency, same library in different version often act different. If you are just join into a new team and you have to use lots of libraries, frameworks, means you have to use lots of time to deal with them in detail stuffs. Using google, mail list, forum, ask others (and maybe them don’t know), cost you lots of time and make yourself upset, unhappy, angry.
I use vagrant to deal with this case.
What’s vagrant? OK, FINE, http://www.iwgtfy.com/?q=vagrant
Technically, vagrant is a virtual machine management tool, means vagrant can help you to build a environment from scratch, package and ship.
I will brief explain how I am using vagrant from scratch, cause it’s document is so nice.
- Install a clean OS. Download a new vagrant clean box file from http://www.vagrantbox.es, using vagrant init to install. I choose Ubuntu Server 12.04 (LTS)
- Log into vagrant to install basic libraries, for me install MySQL, Apache2, Django, django-plugins and so on
- Prepare your code base
- Logout vagrant, using vagrant package command to build your own library installed box file
- Ship this file to new guys, let him use vagrant init and setup the new box in 10 minutes
- Done, he’s already have the whole tool chain to hacking
In here, on step 3, I am not put code into vagrant managed virtual machine. I am using vagrant sync directory to make code base both available in virtual machine and local computer. The reason is VirtualBox’s IO performance is not good, hacking code (via git or some other tools) on local machine is easy and quick. Beside, I can make my vagrant box file holding on a public place (such as s3 or dropbox), and pull my private code into local machine, safe, security, fast, works well.
Till now, it works find. But still some issues. How to make every existing on vagrant environment upgrade libraries and dependencies?
I am not done with this, but I find the answer, using Puppet.
Making the whole thing together, I use git. Make a project, every configuration file, setup script all put here, then holding by Github. Every time upgrade for dev environment, just using git pull and vagrant provision is enough.
Things I can improve,
- Using Puppet to manage every libraries and configuration file, both using on vagrant and production server
- Using Fabric writing remote control script send command to vagrant and production server
- Using virtualenv to manage python code
- Improve vagrant automatic setup script, avoid wget command, cause Mac OS X doesn’t install this by default
It works so well, and I running this for a new guy, using 17 minutes, wonderful.