Skip to content

Instantly share code, notes, and snippets.

@skhameneh
Last active January 21, 2017 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skhameneh/b0f763d6d910082e7c2717e2964a7ce2 to your computer and use it in GitHub Desktop.
Save skhameneh/b0f763d6d910082e7c2717e2964a7ce2 to your computer and use it in GitHub Desktop.
react-dallas-go-starter-kit
# -*- mode: ruby -*-
# vi: set ft=ruby :
$setupScript = <<SCRIPT
GO_VERSION=1.7.4
echo "Downloading go$GO_VERSION.linux-amd64.tar.gz"
wget http://storage.googleapis.com/golang/go$GO_VERSION.linux-amd64.tar.gz >/dev/null 2>&1
echo 'Extracting go'
sudo tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz
echo 'Setting up correct env. variables'
echo 'export GOPATH=/vagrant' >> /home/vagrant/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin' >> /home/vagrant/.bashrc
# Go right to the project directory on login
echo 'cd /vagrant/src/reactdallas.org/reactdallas/go-starter-kit-master' >> /home/vagrant/.bashrc
export GOPATH=/vagrant
export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
mkdir -p /vagrant/src/reactdallas.org/reactdallas/
cd /vagrant/src/reactdallas.org/reactdallas/
echo 'Downloading go-starter-kit'
wget https://github.com/olebedev/go-starter-kit/archive/master.tar.gz >/dev/null 2>&1
echo 'Extracting go-starter-kit'
tar xf ./master.tar.gz -C ./ >/dev/null 2>&1
# Creates a script to Webpack to run as a binary without symlinks
mkdir -p ./go-starter-kit-master/node_modules/.bin
echo './go-starter-kit-master/node_modules/webpack/bin/webpack.js' >> ./node_modules/.bin/webpack
echo 'Running apt-get update & installing curl'
sudo apt-get update -y -qq && sudo apt-get install -y -qq curl
mkdir $GOPATH/bin >/dev/null 2>&1
curl -sL https://glide.sh/get | sh >/dev/null 2>&1
echo 'Installing node 6'
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - >/dev/null 2>&1
sudo apt-get install -y nodejs >/dev/null 2>&1
# Warning: Yarn does not work well with Windows filesystems inside a Linux VM, use "--no-bin-links"
echo 'Installing Yarn'
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - >/dev/null 2>&1
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list >/dev/null 2>&1
sudo apt-get update -y -qq && sudo apt-get install -y -qq yarn >/dev/null 2>&1
echo "\n\n *\n * Congratulations, your VM is ready!\n *\n * You may now run 'vagrant ssh' to enter the VM.\n *\n * In the VM:\n * 'yarn install --no-bin-links' installs node modules.\n * 'make serve' runs the go server.\n *\n * Enjoy!"
SCRIPT
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "minimal/trusty64"
# Map VM port 5001 to host 5001.
config.vm.network "forwarded_port", guest: 5001, host: 5001
config.vm.provision "shell", privileged: false, inline: $setupScript
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment