Last active
October 21, 2018 11:12
-
-
Save bbaaxx/d88d433f402539fafc4e to your computer and use it in GitHub Desktop.
Vagrantfile for a cheap ember-cli box (with NVM)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
box = 'ubuntu/trusty64' | |
hostname = 'emberclibox' | |
domain = 'example.com' | |
ip = '192.168.42.42' | |
ram = '512' | |
$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 | |
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 0.10.33 | |
nvm alias default 0.10.33 | |
npm install -g bower ember-cli | |
SCRIPT | |
VAGRANTFILE_API_VERSION = "2" | |
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: "10.42.42.42" | |
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 |
You should be able to add ember server
to the end of the $userScript
if you add ember s to the end then vagrant provision will not close. You must add the next:
nohup ember s > /dev/null 2>&1 &
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for this. It has helped me a lot.
However, I have a question, after initializing and provisioning the box, how can I start the server? As of now, I'm manually SSH'ing into the box, cd'ing to /vagrant and issuing the command 'ember server'. Any other way to achieve this in a less manual way?