Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Changes needed for vagrant.
  • Loading branch information
Armen Donigian committed Apr 25, 2015
commit 42ea35a5c7f543e3e983b6ea19b9699ef4bbd8e9
20 changes: 19 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,28 @@ VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-i386-vagrant-disk1.box"
config.vm.box = "precise64"
config.ssh.forward_agent = true

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.10.11"
#config.vm.network "private_network", ip: "localhost"
config.vm.network :forwarded_port, host: 5000, guest: 5000

config.vm.provider :virtualbox do |vb, override|

# The Virtualbox image
override.vm.box = "precise64"
override.vm.box_url = "http://files.vagrantup.com/precise64.box"

# Port forwarding details

# Flask
override.vm.network :forwarded_port, host: 5000, guest: 5000

# You can increase the default amount of memory used by your VM by
# adjusting this value below (in MB) and reprovisioning.
vb.customize ["modifyvm", :id, "--memory", "384"]
end

# Setup web server
config.vm.provision "shell", path: 'install_script.sh', args: '/vagrant', privileged: false
Expand Down
12 changes: 7 additions & 5 deletions install_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ sudo apt-get update
sudo apt-get -y install python python-virtualenv nginx supervisor

# install application (source location in $1)
mkdir /home/vagrant/student
cp -R $1/student/* /home/vagrant/student/
mkdir /home/vagrant/students
cp $1/requirements.txt /home/vagrant
cp -R $1/students/* /home/vagrant/students/

# create a virtualenv and install dependencies
virtualenv /home/vagrant/student/venv
/home/vagrant/student/venv/bin/pip install -r /home/vagrant/student/requirements.txt
virtualenv /home/vagrant/students/venv
source /home/vagrant/students/venv/bin/activate
sudo /home/vagrant/students/venv/bin/pip install -r /home/vagrant/requirements.txt

# configure supervisor
sudo cp /vagrant/student.conf /etc/supervisor/conf.d/
Expand All @@ -24,4 +26,4 @@ sudo rm -f /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/student /etc/nginx/sites-enabled/
sudo service nginx restart

echo Application deployed to http://192.168.10.11/
echo Application deployed to http://localhost:5000/
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ itsdangerous==0.24
python-dateutil==2.2
requests==2.3.0
six==1.7.3
flask-bootstrap
flask-bootstrap
gunicorn==19.1.1
4 changes: 2 additions & 2 deletions student.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; supervisor configuration

[program:student]
command=/home/vagrant/student/venv/bin/gunicorn -b 127.0.0.1:5000 -w 4 --chdir /home/vagrant/student --log-file - student:app
[program:students]
command=/home/vagrant/students/venv/bin/gunicorn -b 127.0.0.1:5000 -w 4 --chdir /home/vagrant/students --log-file - students:app
user=vagrant
autostart=true
autorestart=true
Expand Down
4 changes: 2 additions & 2 deletions student.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static {
alias /home/vagrant/student/static;
alias /home/vagrant/students/static;
}
location /favicon.ico {
alias /home/vagrant/student/static/favicon.ico;
alias /home/vagrant/students/static/favicon.ico;
}
}