Environment Parity: Development is Production

Standardizing your environments with Vagrant will help keep you sane

Why invest in a project's development environment?

It is not uncommon for a developer to run a local LAMP stack with MAMP or WAMP for code that will be deployed to a remote server running a completely different operating system (e.g. Ubuntu, CentOS, or RHEL). And this is OK if you're building your own personal website that no other developer will ever touch.

Nowadays code is distributed among, and touched by, a larger number of developers. These developers may be your coworkers, upstream repository contributors, or developers who assume control of your code after you have moved on to newer projects. Your code is very likely a community responsibility.

To protect your sanity, and the sanity of your team members, standardize your development environment across your entire community. Adopt a coding standard (e.g. PHP's PSR-2). Share an identical local development server with specific software versions (e.g. nginx 1.6.0, PHP 5.5.12, and MariaDB 10.0). Let everyone run the exact same code using the exact same software on the exact same operating system. This reduces the potential for bugs caused by platform differences. If a bug does exist, your entire team should be able to duplicate it.

Yes, this practice does incur an upfront overhead to setup and share the development platform. Luckily, this is a "once-and-done" thing and it pays dividends over time.

Match your development and production environments

How can my development environment mirror production?

Short answer: Use Vagrant and Puppet to automatically provision development and production virtual machines!

Longer answer: Create a set of Puppet manifests or Chef recipes for your project. Your company may even have a set of boilerplate provisioning scripts you can recycle from past projects. Agree on a set of specific software and software versions and stick with them. Choose a coding standard and enforce it.

After you provision a Vagrant virtual machine with Puppet or Chef, package it into a custom .box file and distribute it to your team members so they can spin up an identical virtual machine with VirtualBox or VMWare. Use the same provisioning scripts, if possible, to provision your production server using the exact same operating system and software. AWS, Azure, DigitalOcean, Joyent, Rackspace, and Softlayer all provide custom Vagrant providers that make it dead simple to provision a remote server with Vagrant and your provisioner of choice. Use these free plugins to your advantage.

Be smart and standardize early. This saves you from stress and debugging in the long run.

Leave the first comment