Commit c7774f30 by Usman Khalid

Merge pull request #632 from edx/usman/add-vagrant-setup

Added vagrant setup.
parents eeb029dd 4535eeec
...@@ -22,10 +22,9 @@ install-python: ...@@ -22,10 +22,9 @@ install-python:
install-js: install-js:
npm config set loglevel warn sudo npm config set loglevel warn
npm install npm install
install-nltk-data: install-nltk-data:
./scripts/download-nltk-data.sh ./scripts/download-nltk-data.sh
...@@ -40,8 +39,11 @@ javascript: ...@@ -40,8 +39,11 @@ javascript:
install-test: install-test:
pip install -q -r requirements/test.txt pip install -q -r requirements/test.txt
install-dev:
sudo gem install sass
pip install -q -r requirements/dev.txt
install: install-system install-node install-wheels install-python install-js install-nltk-data install-test javascript install: install-system install-node install-wheels install-python install-js install-nltk-data install-test install-dev javascript
test: test:
./scripts/test.sh ./scripts/test.sh
...@@ -7,14 +7,47 @@ User docs: |user-docs| Developer docs: |dev-docs| ...@@ -7,14 +7,47 @@ User docs: |user-docs| Developer docs: |dev-docs|
Installation Installation
============ ============
The intent of this project is to be installed as Django apps that will be The intent of this project is to be installed as Django apps that will be included in `edx-platform <https://github.com/edx/edx-platform>`_.
included in `edx-platform <https://github.com/edx/edx-platform>`_.
To install all dependencies (assumes Ubuntu 12.04): But development is done in the Workbench which is part of the `xblock-sdk <https://github.com/edx/xblock-sdk>`_. Currently Ubuntu 12.04 is assumed. You can setup everything in a Vagrant instance.
To do so install the latest VirtualBox >= 4.3.12 and the latest Vagrant >= 1.6.5.
Clone the repo:
.. code:: bash .. code:: bash
mkdir orastack
cd orastack
git clone git@github.com:edx/edx-ora2.git
Create the Vagrant instance:
.. code:: bash
ln -s ./edx-ora2/Vagrantfile ./
vagrant plugin install vagrant-vbguest
vagrant up
The first vagrant up will fail when setting up shared folders (because the user ora2 does not exist) so do:
.. code:: bash
vagrant provision
vagrant reload
Now you can ssh into the vagrant machine:
.. code:: bash
vagrant ssh
sudo su ora2
To install all dependencies:
.. code:: bash
make install make install
make install-dev
Running the Development Server Running the Development Server
...@@ -25,11 +58,11 @@ Running the Development Server ...@@ -25,11 +58,11 @@ Running the Development Server
./scripts/workbench.sh ./scripts/workbench.sh
Additional arguments are passed to ``runserver``. For example, Additional arguments are passed to ``runserver``. For example,
to start the server on port 8001: to start the server on port 9000:
.. code:: bash .. code:: bash
./scripts/workbench.sh 8001 ./scripts/workbench.sh 0.0.0.0:9000
Combining and Minifying JavaScript and Sass Combining and Minifying JavaScript and Sass
......
Vagrant.require_version ">= 1.5.3"
unless Vagrant.has_plugin?("vagrant-vbguest")
raise "Please install the vagrant-vbguest plugin by running `vagrant plugin install vagrant-vbguest`"
end
VAGRANTFILE_API_VERSION = "2"
MEMORY = 1048
CPU_COUNT = 2
$bashrc = <<SCRIPT
source "/edx/app/ora2/venvs/ora2/bin/activate"
# If X11 forwarding is enabled, then use the DISPLAY value
# already set and use the X11 session cookie
if [ -n "$DISPLAY" ]; then
export XAUTHORITY="/home/vagrant/.Xauthority"
# Otherwise, configure the display to use the virtual frame buffer
else
export DISPLAY=":1"
fi
cd "/edx/app/ora2/edx-ora2"
SCRIPT
$script = <<SCRIPT
export PYTHONUNBUFFERED=1
if id -u ora2 >/dev/null 2>&1; then
echo "User ora2 exists."
else
echo "Creating user ora2."
mkdir -p /edx/app/ora2
sudo useradd -d /edx/app/ora2 -s /bin/bash ora2
sudo adduser --quiet ora2 admin
chown -R ora2:ora2 /edx/app/ora2
sudo -u ora2 echo "#{$bashrc}" >> /edx/app/ora2/.bashrc
fi
sudo apt-get install -y python-pip python-virtualenv
if [ -d "/edx/app/ora2/venvs/ora2" ]; then
echo "Virtualenv exists in /edx/app/ora2/venvs/ora2. Skipping creating one."
else
echo "Creating virtualenv in /edx/app/ora2/venvs/ora2."
sudo -u ora2 virtualenv --clear -q /edx/app/ora2/venvs/ora2
fi
SCRIPT
ora_mount_dir = "edx-ora2"
if ENV['VAGRANT_MOUNT_BASE']
ora2_mount_dir = ENV['VAGRANT_MOUNT_BASE'] + "/" + ora2_mount_dir
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Creates an edX devstack VM from an official release
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.11"
config.vm.network :forwarded_port, guest: 9000, host: 9000
config.vm.network :forwarded_port, guest: 9001, host: 9001
config.ssh.insert_key = true
# Enable X11 forwarding so we can interact with GUI applications
if ENV['VAGRANT_X11']
config.ssh.forward_x11 = true
end
config.vm.synced_folder "#{ora_mount_dir}", "/edx/app/ora2/edx-ora2",
create: true, owner: "ora2", group: "ora2"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", MEMORY.to_s]
vb.customize ["modifyvm", :id, "--cpus", CPU_COUNT.to_s]
# Allow DNS to work for Ubuntu 12.10 host
# http://askubuntu.com/questions/238040/how-do-i-fix-name-service-for-vagrant-client
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
# Use vagrant-vbguest plugin to make sure Guest Additions are in sync
config.vbguest.auto_reboot = true
config.vbguest.auto_update = true
config.vm.provision "shell", inline: $script
end
\ No newline at end of file
...@@ -18,3 +18,4 @@ python2.7-dev ...@@ -18,3 +18,4 @@ python2.7-dev
python-mysqldb python-mysqldb
python-pip python-pip
python-software-properties python-software-properties
rubygems
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment