The Local Problem
- How can I reproduce the issue locally?
- How can I test my code before a deployment?
- How can I work on a website without a network connection?
If you develop on a laptop, you’ve probably faced these three questions before. You might have even come up with your own solutions …Early Solutions
- WAMP
- MAMP
- XAMPP
- Native Installations
I’ve worked with every solution in this list. My Windows machine once had WAMP installed before I moved to XAMPP before I just installed PHP and Nginx and MySQL natively. All of these are complete and utter messes, though.Good Enough?
- Memory usage is horrible
- Disk space is bloated
- Ports are hogged by unnecessary processes
- Upgrades are a nightmare
These early solutions worked, but with all of the extra problems they present(ed), are they good enough?WordPress, Meet Vagrant
- Jeremy Felt
In 2012, Jeremy and a few other 10uppers began working on a Vagrant-powered VM generator called Varying Vagrant Vagrants.Varying Vagrant Vagrants
What’s even better: it’s disposable!
The goal was to create a disposable local environment that somewhat mirrored our production environments. You could shut it off at the end of the day, throw it away when a project was complete, or even install temporary software in the VM and recycle the data when you were done.Evolution
- Bundles the WordPress development suite
- Keeps up-to-date with PHP and MySQL changes
- Empowers simple, local development complete with unit testing, runtime debugging, and even production-style caching
- Continues to evolve with contributions!
Over time, more and more tools were added to VVV to make it an even more robust development environment.Provisioning - Bash
VVV was one of, if not the, earliest implementations of Vagrant in the WordPress world. At the time, and currently, it used Bash scripting to build the entire server. This is easy to follow when you’re getting started, but isn’t very scalable - it targets one Linux distribution and is very fragile if anything updates in the ecosystem.Provisioning - SaltStack
Another project, Salty WordPress by Human Made, uses Salt as a provisioner. Salt is built in Python, so you can use Python scipts and dictionaries to pull things together. It’s very powerful. Salt has been around since 2011, so the community is young but growing.Provisioning - Puppet
Puppet is a similar provisioning tool, written in Ruby. Unlike Salt and Bash, it can also be run on Windows. Puppet has been around since 2005, so it’s got a fairly stable community.Provisioning - Chef
Chef is written in a combination of Ruby and Erlang - for provisioning you’ll most likely use Ruby. Chef has been around since 2009.Provisioning - Ansible
Like Salt, Ansible is written in Python so you can extend it with typical Python code. Unlike Salt, most of Ansible’s commands are self-contained (so you don’t have to pull things from a remote server). Also, unlike Salt, Ansible can run against Windows machines, though you can’t run it with a Windows host - there are workarounds, and they’ve led to Ansible being a powerful distribution/build tool. Ansible has been around since 2012.The Production Problem
- How are new servers spun up?
- How does new code get to the server?
- What happens when things go wrong?
All of the work with provisioners raises the next question: can our work with Vagrant help solve the issues we have in production?Early Solutions
- Check-lists
- Backups
- Institutional memory
Often, when we work with servers, we push code manually, we build servers manually, and we migrate data manually. It’s a huge time sink, and it’s often highly dependent on the people we have today in order to work.Today?
But is it enough? How many of you have a code deployment checklist? How many of you have a server configuration checklist? How many of you have seen parts of those checklists ignored?WPEngine - Mercury Vagrant
- Debug both PHP and HHVM
- Test code prior to deployment
- Emulate the production infrastrcture
- One-click push to production
A popular WordPress host, WPEngine has invested significant time and effort into both building their production environment and a Vagrant-powered emulator for local development. They've also implemented vagrant push functionality, giving developers the power to take their local changes live instantly.Docker
- Build applications inside lightweight, distributable containers
- Isolate key infrastructure components:
- Web server
- Application
- Database
- Easily distribute development environments to the team
Docker is the newest buzzword when it comes to building out scalable infrastructures. It's a tool that allows for accessible containerization of processes, empowering a true separation-of-concerns infrastructure and leading to insanely powerful scalability of hosted application systems.“The things that we know and learn by releasing stuff,we never could have learned otherwise…”
- Matt Mullenweg
Iterate, iterate, iterate ...Closing
If this is the kind of thing that interests you, we're hiring ...
Sandboxing Your Development Environment with Vagrant
Presented by Eric Mann / @ericmann