AboutBlogContact
DevOpsMarch 25, 2012 2 min read 21

Vagrant: Reproducible Dev Environments with VirtualBox (2012)

AunimedaAunimeda

Vagrant: Reproducible Dev Environments with VirtualBox

It’s 2012, and we’re still struggling with the "Works on my machine" syndrome. One dev is on a Mac, another on Windows, and the production server is Ubuntu. Setting up a new project takes days of installing MySQL, Redis, and specific Ruby versions.

Vagrant is changing that. By using a simple Vagrantfile, we can spin up a consistent VirtualBox VM that exactly matches production.

The Vagrantfile

Everything is defined in Ruby. You check this file into Git, and everyone on your team can just run vagrant up.

# Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/precise64"
  
  # Forward a port from the guest to the host
  config.vm.network "forwarded_port", guest: 80, host: 8080
  
  # Share a folder from the host to the guest
  config.vm.synced_folder "./app", "/var/www"
  
  # Provision with a shell script (or Chef/Puppet)
  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get install -y apache2 php5
  SHELL
end

Why it's a win

  1. Isolation: No more "polluting" your main OS with different database versions.
  2. Parity: Your dev environment is actually Linux, even if you’re using Windows.
  3. Speed: vagrant up and you’re ready to code.

In 2012, if you aren't using Vagrant, you're spending too much time on sysadmin work and not enough time on code. Let VirtualBox handle the heavy lifting!

Read Also

Docker Multi-Stage Builds: Slimming Down Your Production Images (2019)aunimeda
DevOps

Docker Multi-Stage Builds: Slimming Down Your Production Images (2019)

Shipping a 1GB Node.js image is so 2017. In 2019, we use multi-stage builds to separate our build environment from our runtime environment, resulting in tiny, secure images.

The Rise of Containerization: Why We are Moving Our Production to Dockeraunimeda
DevOps

The Rise of Containerization: Why We are Moving Our Production to Docker

The 'it works on my machine' era is over. In 2018, we are standardizing our development and production environments using Docker to solve the environment parity problem once and for all.

Dockerizing Your Legacy Rails App: No More 'Works on My Machine' (2013)aunimeda
DevOps

Dockerizing Your Legacy Rails App: No More 'Works on My Machine' (2013)

The Docker revolution is just beginning. In 2013, we're using it to containerize legacy Ruby on Rails apps and solve the dependency nightmare.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

Get Consultation All articles