Node.js starter kit for Ubuntu 14.04 Vagrant box on DigitalOcean
# Provision after up, since digital ocean doesn't respect "privileged" during up
vagrant up --no-provision --provider=digital_ocean
vagrant provision
#!/usr/bin/env bash
echo '>>> Creating swapfile'
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
echo '>>> Fixing locale issues'
sudo sh -c 'echo "LC_ALL=en_US.UTF-8\nLANG=en_US.UTF-8" > /etc/default/locale'
. /etc/default/locale
echo '>>> Updating Ubuntu packages'
sudo apt-get update
sudo apt-get -y dist-upgrade
echo '>>> Setting timezone and syncing with NTP'
# Find your timezone using timedatectl list-timezones or just use "UTC"
sudo timedatectl set-timezone ADD_YOUR_TIMEZONE_HERE
sudo apt-get -y install ntp
echo '>>> Installing nvm and node'
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
. ~/.nvm/nvm.sh
nvm install node
nvm alias default node
nvm use node
npm i -g npm
echo '>>> Installing MongoDB'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get -y install mongodb-org
echo '>>> Installing nginx'
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get -y install nginx
echo '>>> Installing git'
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get -y install git
Vagrant.configure('2') do |config|
config.vm.hostname = 'vagrant-example'
config.vm.provider :digital_ocean do |provider, override|
override.ssh.username = 'vagrant'
override.ssh.private_key_path = '~/.ssh/id_rsa'
override.vm.box = 'digital_ocean'
override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
provider.token = ENV['DIGITAL_OCEAN_TOKEN']
provider.image = 'ubuntu-14-04-x64'
provider.region = 'sgp1'
provider.size = '512mb'
end
config.vm.provision :shell, path: 'provision.sh', privileged: false
end