Skip to content

Commit

Permalink
Merge pull request #4 from ProjetSigma/feature/vagrant-node
Browse files Browse the repository at this point in the history
Add vagrant provisioning for the frontend
  • Loading branch information
Albéric Trancart committed Dec 14, 2015
2 parents ed5ba96 + 4c6d17b commit 7c4a272
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ to launch the client:
cd /vagrant/frontend
npm start

*Warning: the client is not provisioned yet*

The backend and frontend will then be available at localhost:8000 and localhost:5555 on your host machine, and you can start coding as usual !

To reprovision the vagrant in case provisioning changed:
Expand Down
18 changes: 9 additions & 9 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |django_config|
Vagrant.configure("2") do |config|
# Every Vagrant virtual environment requires a box to build off of.
django_config.vm.box = "ubuntu/vivid64"
config.vm.box = "ubuntu/vivid64"

# Configure virtual machine specs. Keep it simple, single user.
django_config.vm.provider :virtualbox do |p|
config.vm.provider :virtualbox do |p|
p.customize ["modifyvm", :id, "--memory", 1024]
p.customize ["modifyvm", :id, "--cpus", 1]
# p.customize ["modifyvm", :id, "--cpuexecutioncap", 50]
end

# Configure a synced folder between HOST and GUEST
django_config.vm.synced_folder "..", "/vagrant", id: "vagrant-root", :mount_options => ["dmode=777","fmode=666"]
config.vm.synced_folder "..", "/vagrant", id: "vagrant-root", :mount_options => ["dmode=777","fmode=666"]

# Config hostname and IP address so entry can be added to HOSTS file
django_config.vm.hostname = "vagrant"
django_config.vm.network :private_network, ip: '192.168.87.7'
config.vm.hostname = "vagrant"
config.vm.network :private_network, ip: '192.168.87.7'

# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
django_config.vm.network "forwarded_port", guest: 8000, host: 8000
django_config.vm.network "forwarded_port", guest: 5555, host: 5555
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network "forwarded_port", guest: 5555, host: 5555

# kickoff a shell script to install Python essentials
django_config.vm.provision :shell, path: "vagrant_bootstrap.sh"
config.vm.provision :shell, path: "vagrant_bootstrap.sh"
end
16 changes: 12 additions & 4 deletions vagrant_bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
echo 'Installing required packages...'
sudo apt-get -yqq install git python3-pip python-dev libmysqlclient-dev libjpeg-dev
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
DISTRO="vivid"
sudo sh -c "echo 'deb https://deb.nodesource.com/node_5.x ${DISTRO} main' > /etc/apt/sources.list.d/nodesource.list"
sudo sh -c "echo 'deb-src https://deb.nodesource.com/node_5.x ${DISTRO} main' >> /etc/apt/sources.list.d/nodesource.list"

sudo apt-get update
sudo apt-get -yqq install git python3-pip python-dev libmysqlclient-dev libjpeg-dev \
build-essential apt-transport-https nodejs

cd /vagrant/backend
echo 'Installing pip dependencies...'
sudo pip3 install -r requirements.txt
echo "Running migrations..."
python3 manage.py migrate

# Todo: install npm; build app
# cd /vagrant/frontend

cd /vagrant/frontend
sudo npm install -g tsd gulp
npm install --loglevel=info

echo ""
echo "Vagrant install complete."
Expand Down

0 comments on commit 7c4a272

Please sign in to comment.