Having gone through the onerous task of selecting what type of laptop I wanted at Red Badger (13" MacBook Pro with 16gb RAM and 512gb SSD) and waiting impatiently for it to be delivered, it was time to get it ready to use.
My previous personal Mac, a late 2010 11" Air, has done sterling service - even just about managing when asked to run a couple of virtual machines concurrently alongside a Node.js environment. But it was starting to creak a bit and the poor thing's SSD was chock full of all the random crap that had been installed to support various projects. So as well as the stuff I regularly use there were also leftover bits and pieces of Java, Python and who knows what else.
At Red Badger we've largely adopted Vagrant and Chef as a great way of provisioning development environments without imposing on the personal space of your own laptop. Clone a repo from Github, run 'vagrant up' on the project directory, the Vagrant script installs and configures a VM for you, 'vagrant ssh' and there you are with a fresh, clean dev environment that can be reconfigured, reloaded and chucked away as often as you like. Joe is going to be writing more about this process soon.
So I decided, I would challenge myself to install the bare minimum of tooling to get up and running, with all the stuff specific to our current project residing in a virtual machine. This should also, in theory, make a nice solid base for general front-end development to current practices. And hopefully leave 400gb -odd of disc space to fill up with bad music and animated cat gifs.
The clock was ticking...
- Google Chrome - goes without saying really (3 mins)
- Node.js - nice and easy these days with a pre-packaged installer available for Mac, Windows and Linux (5 mins)
- Useful Node global modules - First trip into the terminal to 'sudo npm install -g ...' for coffee-script, grunt, express, less, nodemon and jamjs. This is by no means an exhaustive list but gives me all the Node-based essentials to build and run projects. (5 mins)
- Xcode Command Line Tools - Rather than the enormous heft of all of Xcode, the command line tools are a relatively slimline 122mb and give you the bits you need (as a web rather than OS developer) to compile the source code of stuff like wget. An Apple developer account is needed for this so I can't give a direct link, unfortunately. (15 mins)
- Git - Last time I did this I'm sure there was a fair amount of messing around but there is now an installer package for OS X (5 mins)
- Virtual Box - This is where we start getting in to the real time saving stuff. Virtual Box is a free VM platform which can be scripted, essential for the next part (10 mins)
- Vagrant - This is the key part, as explained in the introduction. Once Vagrant is up and running, a pre-configured dev environment can be there in just a few minutes (3 mins)
- Github ssh key config - Back to the command line. To be able to clone our project from its Github repo I had to remember how to do this, and the documentation on the Github site doesn't have the best signposting. (5 mins)
- Clone repo and post-install tasks - Get the code down, then run 'npm install' and 'jam install' in the project directory to fetch server and client dependencies. Run 'grunt && grunt watch' to build CoffeeScript, Less and Jade source into application code and then watch for file changes. (2 mins)
- Vagrant up - With the repo cloned and ready, the 'vagrant up' command downloads the specified VM image and then boots it and installs the relevant software. In this case, Node and MongoDB. At a touch over 300mb to download (albeit a one-off if you use the same image on subsequent projects) this is the longest part of the whole process (20 mins).
- Vagrant ssh - Log into the new virtual machine, change to the /vagrant directory which mounts all your locally held app code, run 'node app/app.js'. Hit Vagrant's IP address in Chrome (see step 1) and you're there (1 min).
So there we go. By my reckoning 74 mins from logging in to the laptop to being able to get back to productivity. And because the VM environment is identical to where I was on my old Mac I could literally carry on from my last Git commit. I did those steps above sequentially to time them, but at the same time was installing the Dropbox client for project assets and Sublime Text for something to code in.
Obviously on a new project you would have the added overhead of configuring and testing your Vagrant scripts, but this only has to be done once and then when your team scales everyone can get to parity in a few minutes rather than the hours it might once have taken.
Vagrant really is one of those tools you wish you'd known about (or that had existed) a long time ago and really feels like a step change for quick, painless and agile development. This is also the first project I've really used Grunt on, and its role in automation and making your coding life easier has already been widely celebrated. Hence the title of this post, because this feels like the first step in a general refresh of the way I do things and hopefully I'll be writing more about this journey soon.