Skip to content

Instantly share code, notes, and snippets.

@dolcalmi
Created July 2, 2015 02:58
Show Gist options
  • Save dolcalmi/659f3f46bc6935314f52 to your computer and use it in GitHub Desktop.
Save dolcalmi/659f3f46bc6935314f52 to your computer and use it in GitHub Desktop.
Vagrant file for ember-cli app based on https://gist.github.com/bbaaxx/d88d433f402539fafc4e
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
box = 'ubuntu/trusty64'
hostname = 'emberclibox'
domain = 'embertest.local'
ip = '192.168.13.100'
ram = '768' # 512 throws an out of memory exception in npm install -g ember-cli
$rootScript = <<SCRIPT
echo "I am provisioning..."
echo doing it as $USER
cd /home/vagrant
add-apt-repository ppa:git-core/ppa
apt-get update
apt-get install -y vim git-core curl
SCRIPT
$userScript = <<SCRIPT
echo doing it as $USER
cd /home/vagrant
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
export NVM_DIR="/home/vagrant/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm install stable > /dev/null 2>&1
nvm alias default stable
if which bower >/dev/null; then
echo bower exists
else
npm install -g bower
fi
if which ember >/dev/null; then
echo ember exists
else
npm install -g ember-cli
fi
cd /vagrant/
npm install
bower install
nohup ember s > /dev/null 2>&1 &
echo staring ember serve
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = box
config.vm.hostname = hostname
# Forwarding default ports for ember server and livereload
config.vm.network :forwarded_port, guest: 4200, host: 4200, auto_correct: true
config.vm.network :forwarded_port, guest: 35729, host: 35729, auto_correct: true
config.vm.network "private_network", ip: ip
config.ssh.forward_agent = true
config.vm.synced_folder ".", "/vagrant",
owner: "vagrant", group: "vagrant"
# Removes "stdin: is not a tty" annoyance as per
# https://github.com/SocialGeeks/vagrant-openstack/commit/d3ea0695e64ea2e905a67c1b7e12d794a1a29b97
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.provider "virtualbox" do |vb|
vb.customize [
"modifyvm", :id,
"--memory", ram,
]
# Allow the creation of symlinks for nvm
# http://blog.liip.ch/archive/2012/07/25/vagrant-and-node-js-quick-tip.html
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant","1"]
end
# Shell provisioning.
config.vm.provision "shell", inline: $rootScript
config.vm.provision "shell", inline: $userScript, privileged: false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment