Created
January 19, 2017 23:04
-
-
Save dmpayton/772ff6341c59b62e4c004b0112f1aa89 to your computer and use it in GitHub Desktop.
Django/Node Vagrant
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
#!/bin/bash | |
######### | |
## Setup | |
# Ensure everything is up to date | |
echo "Updating the system..." | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
# Build tools and pre-reqs | |
echo "Installing developer tools..." | |
sudo apt-get -y install git build-essential libjpeg-dev libtiff5-dev zlib1g-dev | |
# libfreetype6-dev ziblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk | |
# bash history completion | |
wget https://raw.githubusercontent.com/dmpayton/dotfiles/master/.inputrc -O ~ubuntu/.inputrc | |
chown ubuntu:ubuntu ~ubuntu/.inputrc | |
########## | |
## Python | |
echo "Installing Python 3..." | |
sudo apt-get install -y python3 python3-dev | |
# pip | |
wget https://bootstrap.pypa.io/get-pip.py -O - | python3.5 | |
# virtualenv | |
echo "Installing and configuring virtualenv and virtualenvwrapper..." | |
sudo pip install virtualenv virtualenvwrapper | |
mkdir ~ubuntu/.virtualenvs | |
printf "\n\n# Virtualenv settings\n" >> ~ubuntu/.bashrc | |
printf "export PYTHONPATH=/usr/lib/python3.5\n" >> ~ubuntu/.bashrc | |
printf "export WORKON_HOME=~ubuntu/.virtualenvs\n" >> ~ubuntu/.bashrc | |
printf "export PROJECT_HOME=/vagrant\n" >> ~ubuntu/.bashrc | |
printf "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.5\n" >> ~ubuntu/.bashrc | |
printf "source /usr/local/bin/virtualenvwrapper.sh\n" >> ~ubuntu/.bashrc | |
printf "workon venv\n" >> ~ubuntu/.bashrc | |
export PYTHONPATH=/usr/lib/python3.5 | |
export WORKON_HOME=~ubuntu/.virtualenvs | |
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.5 | |
source /usr/local/bin/virtualenvwrapper.sh | |
mkvirtualenv venv | |
chown -R ubuntu:ubuntu ~ubuntu/.virtualenvs | |
######## | |
## Node | |
echo "Installing Node.js..." | |
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
############## | |
## PostgreSQL | |
echo "Installing PostgreSQL..." | |
apt-get install -y postgresql libpq-dev | |
# Create vagrant pgsql superuser | |
su - postgres -c "createuser --superuser vagrant" | |
############# | |
## Memcached | |
echo "Installing Memcached..." | |
apt-get install -y memcached libmemcached-dev | |
######### | |
## Done! | |
echo "" | |
echo "Vagrant setup complete!" | |
echo "Now try logging in:" | |
echo " $ vagrant ssh" |
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 : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "ubuntu/xenial64" | |
# Forward a port from the guest to the host, which allows for outside | |
# computers to access the VM, whereas host only networking does not. | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.network "forwarded_port", guest: 8000, host: 8000 | |
# Configure virtual machine specs. Keep it simple, single user. | |
config.vm.provider :virtualbox do |p| | |
p.customize ["modifyvm", :id, "--memory", 2048] | |
p.customize ["modifyvm", :id, "--cpus", 2] | |
p.customize ["modifyvm", :id, "--cpuexecutioncap", 50] | |
end | |
# Config hostname and IP address so entry can be added to HOSTS file | |
config.vm.hostname = "vagrant" | |
# Configure a synced folder between HOST and GUEST | |
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", :mount_options => ["dmode=777","fmode=777"] | |
# Kick off a shell script to install dependencies | |
config.vm.provision "shell", path: "./vagrant-provision.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment