Skip to content

Instantly share code, notes, and snippets.

@louisdorard
Created July 27, 2013 17:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save louisdorard/6095624 to your computer and use it in GitHub Desktop.
Save louisdorard/6095624 to your computer and use it in GitHub Desktop.
An example Vagrant file with port forwarding, shared folder between host and guest, and shell script provisioning.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "lucid32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network :forwarded_port, guest: 80, host: 8080
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "../data", "/vagrant_data"
# Run the specified shell script when creating the VM. The "provision"
# line tells Vagrant to use the shell provisioner to setup the machine,
# with the bootstrap.sh file. The file path is relative to the location
# of the project root (where the Vagrantfile is).
config.vm.provision :shell, :path => "bootstrap.sh"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment