Created
February 16, 2019 21:34
-
-
Save sherman/7aa6b81b99d37e8c510c83874170f026 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
# Install NVM for simple node.js version management | |
curl -s -o- -L https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | |
# This enables NVM without a logout/login | |
export NVM_DIR="/home/vagrant/.nvm" | |
# shellcheck source=/dev/null | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
# Install Node, React for UI development | |
node_version=11.9.0 | |
nvm install ${node_version} | |
nvm alias default ${node_version} | |
npm install -g create-react-app | |
# Install Yarn from its official deb package repository | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
sudo apt-get update | |
sudo apt-get install -y yarn | |
# Install Java Runtime to run closure-compiler and closure-stylesheets | |
sudo apt-get install -y default-jre-headless java-wrappers |
This file contains hidden or 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 : | |
# | |
Vagrant.configure(2) do |config| | |
# Compilation and development box | |
config.vm.define "linux", autostart: true, primary: true do |vmCfg| | |
vmCfg.vm.box = "mokote/debian9" | |
vmCfg.vm.hostname = "hyper-linux" | |
vmCfg = configureProviders vmCfg, | |
cpus: suggestedCPUCores() | |
vmCfg = configureLinuxProvisioners(vmCfg) | |
vmCfg.vm.synced_folder ".", "/vagrant", disabled: true | |
vmCfg.vm.synced_folder ".", "/opt/gopath/src/hyper" | |
vmCfg.vm.synced_folder ENV["HOME"] + "/Library/Caches/go-dl", "/opt/gopath/dl", create: true | |
# Expose hyper API to the host | |
vmCfg.vm.network :forwarded_port, guest: 8500, host: 8500, auto_correct: true | |
# Expose UI ports to the host (one for the site, one for hot-reload) | |
vmCfg.vm.network :forwarded_port, guest: 8501, host: 8501, auto_correct: true | |
vmCfg.vm.network :forwarded_port, guest: 48501, host: 48501, auto_correct: true | |
end | |
end | |
def configureLinuxProvisioners(vmCfg) | |
vmCfg.vm.provision "shell", | |
name: 'config', | |
privileged: true, | |
path: './scripts/vagrant-linux-priv-config.sh' | |
vmCfg.vm.provision "shell", | |
name: 'go', | |
privileged: true, | |
path: './scripts/vagrant-linux-priv-go.sh' | |
vmCfg.vm.provision "shell", | |
name: 'python', | |
privileged: true, | |
path: './scripts/vagrant-linux-priv-python.sh' | |
vmCfg.vm.provision "shell", | |
name: 'postgres', | |
privileged: true, | |
path: './scripts/vagrant-linux-priv-postgres11.sh' | |
vmCfg.vm.provision "shell", | |
name: 'tmux', | |
privileged: true, | |
path: './scripts/vagrant-linux-priv-tmux.sh' | |
vmCfg.vm.provision "shell", | |
name: 'ui', | |
privileged: false, | |
path: './scripts/vagrant-linux-unpriv-ui.sh' | |
vmCfg.vm.provision "shell", | |
name: 'bootstrap', | |
privileged: false, | |
path: './scripts/vagrant-linux-unpriv-bootstrap.sh' | |
return vmCfg | |
end | |
def configureProviders(vmCfg, cpus: "2", memory: "2048") | |
vmCfg.vm.provider "virtualbox" do |v| | |
v.memory = memory | |
v.cpus = cpus | |
end | |
["vmware_fusion", "vmware_workstation"].each do |p| | |
vmCfg.vm.provider p do |v| | |
v.enable_vmrun_ip_lookup = false | |
v.vmx["memsize"] = memory | |
v.vmx["numvcpus"] = cpus | |
end | |
end | |
return vmCfg | |
end | |
def suggestedCPUCores() | |
case RbConfig::CONFIG['host_os'] | |
when /darwin/ | |
Integer(`sysctl -n hw.ncpu`) / 2 | |
when /linux/ | |
Integer(`cat /proc/cpuinfo | grep processor | wc -l`) / 2 | |
else | |
2 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment