Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 6b1bca3

Browse files
author
Hans Kristian Flaatten
committed
Add virtual machine config
1 parent 3297bca commit 6b1bca3

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

Vagrantfile

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Boostrap Script
5+
$script = <<SCRIPT
6+
7+
# Update & Install
8+
echo 'Updating and installing ubuntu packages...'
9+
apt-get update
10+
apt-get install -y build-essential git curl
11+
12+
# Install NodeJS via NVM
13+
echo "Installing Node via NVM..."
14+
export HOME=/home/vagrant
15+
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
16+
echo "source ~/.nvm/nvm.sh" >> /home/vagrant/.bashrc
17+
source /home/vagrant/.nvm/nvm.sh
18+
#nvm install 0.8
19+
nvm install 0.10
20+
#nvm install 0.11
21+
export HOME=/home/root
22+
23+
# Set Environment Varaibles
24+
echo "Setting environment variables..."
25+
echo "export NODE_ENV=development" >> /home/vagrant/.bashrc
26+
echo "cd /vagrant" >> /home/vagrant/.bashrc
27+
28+
# NPM package install
29+
echo "Installing NPM packages..."
30+
echo "PATH=$PATH:/vagrant/node_modules/.bin" >> /home/vagrant/.bashrc
31+
PATH=$PATH:/vagrant/node_modules/.bin
32+
cd /vagrant && rm -rf node_modules
33+
[ -f package.json ] && npm install
34+
35+
# Clean up permissions
36+
chown -R vagrant:vagrant /home/vagrant/.nvm
37+
chown -R vagrant:vagrant /home/vagrant/tmp
38+
39+
SCRIPT
40+
41+
Vagrant.configure("2") do |config|
42+
# All Vagrant configuration is done here. The most common configuration
43+
# options are documented and commented below. For a complete reference,
44+
# please see the online documentation at vagrantup.com.
45+
46+
# Every Vagrant virtual environment requires a box to build off of.
47+
config.vm.box = "precise32"
48+
49+
# The url from where the 'config.vm.box' box will be fetched if it
50+
# doesn't already exist on the user's system.
51+
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
52+
53+
# Create a forwarded port mapping which allows access to a specific port
54+
# within the machine from a port on the host machine. In the example below,
55+
# accessing "localhost:8080" will access port 80 on the guest machine.
56+
# config.vm.network :forwarded_port, guest: 3000, host: 3000
57+
58+
# A Vagrant plugin that helps you reduce the amount of coffee you drink while
59+
# waiting for boxes to be provisioned by sharing a common package cache among
60+
# similiar VM instances. Kinda like vagrant-apt_cache or this magical snippet
61+
# but targetting multiple package managers and Linux distros.
62+
if Vagrant.has_plugin?("vagrant-cachier")
63+
config.cache.auto_detect = true
64+
65+
# For VirtualBox, we want to enable NFS for shared folders
66+
# config.cache.enable_nfs = true
67+
end
68+
69+
# The shell provisioner allows you to upload and execute a script as the root
70+
# user within the guest machine.
71+
config.vm.provision :shell, :inline => $script
72+
73+
# Create a private network, which allows host-only access to the machine
74+
# using a specific IP.
75+
# config.vm.network :private_network, ip: "192.168.33.10"
76+
77+
# Create a public network, which generally matched to bridged network.
78+
# Bridged networks make the machine appear as another physical device on
79+
# your network.
80+
# config.vm.network :public_network
81+
82+
# Share an additional folder to the guest VM. The first argument is
83+
# the path on the host to the actual folder. The second argument is
84+
# the path on the guest to mount the folder. And the optional third
85+
# argument is a set of non-required options.
86+
# config.vm.synced_folder "../data", "/vagrant_data"
87+
88+
# Provider-specific configuration so you can fine-tune various
89+
# backing providers for Vagrant. These expose provider-specific options.
90+
# Example for VirtualBox:
91+
92+
config.vm.provider :virtualbox do |vb|
93+
vb.customize ["modifyvm", :id, "--memory", "256"]
94+
end
95+
96+
end

0 commit comments

Comments
 (0)