Last active
August 29, 2015 14:09
-
-
Save florentb/eeca1ea83722e9df559c to your computer and use it in GitHub Desktop.
Vagrant NodeJS + MongoDB + Redis
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
#!/bin/bash | |
# update packages | |
apt-get update | |
apt-get upgrade -y | |
# core packages | |
apt-get -y -q install \ | |
software-properties-common \ | |
python-software-properties \ | |
python \ | |
curl \ | |
g++ \ | |
make \ | |
libssl-dev \ | |
build-essential \ | |
openssl \ | |
libssl-dev \ | |
unicode-data \ | |
git-core \ | |
pkg-config \ | |
vim \ | |
screen \ | |
# add ppa's to sources | |
## node | |
add-apt-repository -y ppa:chris-lea/node.js | |
## redis | |
add-apt-repository -y ppa:chris-lea/redis-server | |
## mongo | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | |
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list | |
# update sources | |
apt-get -y update | |
# install packages | |
apt-get -y -q install \ | |
nodejs \ | |
redis-server \ | |
mongodb-org | |
# npm packages | |
npm install -g jshint bower gulp grunt-cli anywhere forever |
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 : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.host_name = 'trusty64-nodejs' | |
config.vm.provider :virtualbox do |vb| | |
host = RbConfig::CONFIG['host_os'] | |
# Give VM 1/4 system memory & access to all cpu cores on the host | |
if host =~ /darwin/ | |
cpus = `sysctl -n hw.ncpu`.to_i | |
# sysctl returns Bytes and we need to convert to MB | |
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4 | |
elsif host =~ /linux/ | |
cpus = `nproc`.to_i | |
# meminfo shows KB and we need to convert to MB | |
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4 | |
else # sorry Windows folks, I can't help you | |
cpus = 4 | |
mem = 1024 | |
end | |
vb.customize ["modifyvm", :id, "--memory", mem] | |
vb.customize ["modifyvm", :id, "--cpus", cpus] | |
vb.customize ["modifyvm", :id, "--ioapic", "on" ] | |
end | |
config.vm.provision :shell, :path => "bootstrap.sh" | |
config.vm.network "public_network" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment