From 42ea35a5c7f543e3e983b6ea19b9699ef4bbd8e9 Mon Sep 17 00:00:00 2001 From: Armen Donigian Date: Sat, 25 Apr 2015 13:16:32 -0700 Subject: [PATCH] Changes needed for vagrant. --- Vagrantfile | 20 +++++++++++++++++++- install_script.sh | 12 +++++++----- requirements.txt | 3 ++- student.conf | 4 ++-- student.nginx | 4 ++-- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 04f9dc0..2f584a1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/install_script.sh b/install_script.sh index 9cbbdd7..8791c5a 100644 --- a/install_script.sh +++ b/install_script.sh @@ -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/ @@ -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/ diff --git a/requirements.txt b/requirements.txt index db83ae4..c44afd3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,5 @@ itsdangerous==0.24 python-dateutil==2.2 requests==2.3.0 six==1.7.3 -flask-bootstrap \ No newline at end of file +flask-bootstrap +gunicorn==19.1.1 \ No newline at end of file diff --git a/student.conf b/student.conf index 6ef930e..d5893ff 100644 --- a/student.conf +++ b/student.conf @@ -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 diff --git a/student.nginx b/student.nginx index 673ecbc..10a2da0 100644 --- a/student.nginx +++ b/student.nginx @@ -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; } }