Did you know that you can navigate the posts by swiping left and right?
Few months ago I attended Ruby User Group meetup in Berlin at Wimdu’s office. Jan Schulte was speaking about his development environment enclosed in a virtual machine managed by Vagrant. The idea was always appealing to me and I tried it multiple times. Unfortunately I stumbled upon blockers which brought me always back to native environment. One of the Issues I raised in Q&A part was: how to keep the code editor responsive while accessing files on virtual machine.
Almost month later I decided to try to connect Elixir/Phoenix framework with the newest Ember.js and create small, deployable prototype. It was an amazing weekend hackathon I will describe in later post. The problem occurred on Monday, when it turned out that not every stack has so great tools like RVM and bundler and I need to somehow bring back the old version of Node.js to my computer (NVM was sort of not working for me). Bummer! After fixing the issue I started to think how to avoid it in the future. What if I would want to test another version of Erlang or, even more tricky, see how the newest version of PostgreSQL is doing?
Naturally I turned to VMs and Vagrant. I had few major concerns though:
First, I decided to benchmark the three major VMs solutions compatible with Vagrant: VirtualBox, Parallels and VMWare. I decided to not apply any optimization hacks nor to tune the database. I ran simply the RSpec test suite from the project I work on. Thus following results are not representative and should not be taken as such (YMMV). When making your decision you might want to consider the cost factor (in brackets). Here are my results:
I went with the trial version of VMware to see how much I can get from the VM.
As the next step I reviewed my shell and Emacs configuration. I was able to trim the first down to few files, which can be easily installed inside the machine. I just had to make few adjustments like to make the ssh key forwarding work in tmux. The point of using tmux is to not require new ssh connection, when you need just another she’ll inside the VM. Normally I use iTerm2, so I could benefit from deep tmux integration, which works really great these days. When I connect to the VM, I just launch new tmux session and then the regular iTerm shortcuts open tabs and windows inside the machine! Actually, thanks to iTerm profiles I could change the appearance of the tmux session and by the background color I can tell where particular session belongs to.
Okay, you might ask, how to preserve such environment? Indeed, the VM images are not the only option. There are few provision era supported by Vagrant out of the box. My favorite is Ansible. I coded the whole development environment in it and I am able to destroy and recreate it in 30 minutes (while I am doing something else). Quit hint: you really do want to lock on particular versions of the software you are installing, otherwise you’ll be exposed to nasty surprises.
I am successfully working in an isolated environment since few weeks. I discovered that it has several, either technical and lifestyle, benefits. Many start with the statement that the strongest advantage of using provisioned virtual machines as a development environment is the possibility of sharing it among your team. I don’t think so. The biggest advantage is the ability to separate your work, hobby and fun, while still possessing only one machine.