summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile11
-rw-r--r--online_test/settings.py4
-rw-r--r--requirements/requirements-codeserver.txt1
-rw-r--r--requirements/requirements-common.txt1
-rw-r--r--tasks.py48
-rw-r--r--yaksh/scripts/yaksh_script.sh13
6 files changed, 48 insertions, 30 deletions
diff --git a/Dockerfile b/Dockerfile
index 5928369..f9d4b5f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,11 +4,8 @@ MAINTAINER FOSSEE <pythonsupport@fossee.in>
# Update Packages and Install Python & net-tools
RUN apt-get update && \
apt-get install -y software-properties-common && \
-add-apt-repository ppa:webupd8team/java -y && \
+echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
+add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
-apt-get install -y software-properties-common python net-tools git python3-pip vim libmysqlclient-dev scilab build-essential oracle-java8-installer && \
-mkdir /Sites
-
-VOLUME /src/online_test
-
-WORKDIR /src/online_test
+apt-get install -y oracle-java8-installer && \
+apt-get install -y sudo software-properties-common python net-tools git python3-pip vim libmysqlclient-dev scilab build-essential
diff --git a/online_test/settings.py b/online_test/settings.py
index a690d46..790083e 100644
--- a/online_test/settings.py
+++ b/online_test/settings.py
@@ -15,7 +15,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# The directory where user data can be saved. This directory will be
# world-writable and all user code will be written and saved here by the
# code server with each user having their own sub-directory.
-OUTPUT_DIR = os.path.join(BASE_DIR, 'output')
+OUTPUT_DIR = os.path.join(BASE_DIR, "yaksh_data", "output")
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
@@ -98,7 +98,7 @@ SOCIAL_AUTH_LOGIN_ERROR_URL = '/exam/login/'
MEDIA_URL = "/data/"
-MEDIA_ROOT = os.path.join(BASE_DIR, "yaksh", "data")
+MEDIA_ROOT = os.path.join(BASE_DIR, "yaksh_data", "data")
# Set this varable to <True> if smtp-server is not allowing to send email.
EMAIL_USE_TLS = False
diff --git a/requirements/requirements-codeserver.txt b/requirements/requirements-codeserver.txt
index 29b6568..e44f592 100644
--- a/requirements/requirements-codeserver.txt
+++ b/requirements/requirements-codeserver.txt
@@ -1,3 +1,4 @@
+six
requests
tornado
psutil
diff --git a/requirements/requirements-common.txt b/requirements/requirements-common.txt
index 895b4f9..ff7a901 100644
--- a/requirements/requirements-common.txt
+++ b/requirements/requirements-common.txt
@@ -1,4 +1,5 @@
-r requirements-codeserver.txt
+invoke==0.21.0
django==1.9.5
django-taggit==0.18.1
pytz==2016.4
diff --git a/tasks.py b/tasks.py
index 07c252c..66ea233 100644
--- a/tasks.py
+++ b/tasks.py
@@ -3,14 +3,13 @@ from invoke import task
import os
from yaksh.settings import SERVER_POOL_PORT
-
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
TARGET_CONTAINER_NAME = 'yaksh_code_server'
-SRC_IMAGE_NAME = 'yaksh_image'
+SRC_IMAGE_NAME = 'yaksh_code_server_image'
def create_dir(path):
if not os.path.exists(path):
- ctx.run("mkdir {0}".format(path))
+ os.makedirs(path)
@task
def setupdb(ctx):
@@ -18,8 +17,8 @@ def setupdb(ctx):
ctx.run("python manage.py migrate")
@task(setupdb)
-def run(ctx):
- print("** Running the Django web server **")
+def serve(ctx):
+ print("** Running the Django web server. Press Ctrl-C to Exit **")
ctx.run("python manage.py runserver")
@task
@@ -37,7 +36,7 @@ def getimage(ctx, image=SRC_IMAGE_NAME):
ctx.run("sudo docker pull {0}".format(image))
@task
-def runcodeserver(ctx, ports=SERVER_POOL_PORT, image=SRC_IMAGE_NAME, unsafe=False):
+def start(ctx, ports=SERVER_POOL_PORT, image=SRC_IMAGE_NAME, unsafe=False):
if unsafe:
with ctx.cd(SCRIPT_DIR):
ctx.run("sudo python -m yaksh.code_server")
@@ -45,19 +44,42 @@ def runcodeserver(ctx, ports=SERVER_POOL_PORT, image=SRC_IMAGE_NAME, unsafe=Fals
cmd_params = {'ports': ports,
'image': SRC_IMAGE_NAME,
'name': TARGET_CONTAINER_NAME,
- 'vol_mount_dest': '/src/online_test/',
- 'vol_mount_src': os.path.join(SCRIPT_DIR),
- 'command': 'sh /src/yaksh_script.sh',
+ 'vol_mount': os.path.join(SCRIPT_DIR, 'yaksh_data/'),
+ 'command': 'sh {0}'.format(
+ os.path.join(SCRIPT_DIR,
+ 'yaksh_data/yaksh/scripts/yaksh_script.sh')
+ )
}
getimage(ctx, image=SRC_IMAGE_NAME)
- create_dir(os.path.join(SCRIPT_DIR, 'output/'))
- create_dir(os.path.join(SCRIPT_DIR, 'yaksh/data/'))
+ create_dir(os.path.join(SCRIPT_DIR, 'yaksh_data/data'))
+ create_dir(os.path.join(SCRIPT_DIR, 'yaksh_data/output'))
+
+ ctx.run('cp -r {0} {1}'.format(
+ os.path.join(SCRIPT_DIR, 'yaksh/'),
+ os.path.join(SCRIPT_DIR, 'yaksh_data/')
+ )
+ )
+ ctx.run('cp {0} {1}'.format(
+ os.path.join(SCRIPT_DIR, 'requirements/requirements-codeserver.txt'),
+ os.path.join(SCRIPT_DIR, 'yaksh_data')
+ )
+ )
ctx.run(
- "sudo docker run --privileged \
+ "sudo docker run \
-dp {ports}:{ports} --name={name} \
- -v {vol_mount_src}:{vol_mount_dest} \
+ -v {vol_mount}:{vol_mount} \
+ -w {vol_mount} \
{image} {command}".format(**cmd_params)
)
+
+@task
+def stop(ctx, container=TARGET_CONTAINER_NAME, hide=True):
+ result = ctx.run("sudo docker ps -q --filter='name={0}'".format(container))
+ if result.stdout:
+ print ("** Discarding the docker container <{0}>".format(container))
+ ctx.run("sudo docker rm {0}".format(container))
+ else:
+ print("** Docker container <{0}> not found **".format(container))
diff --git a/yaksh/scripts/yaksh_script.sh b/yaksh/scripts/yaksh_script.sh
index 83c086c..f19ad3d 100644
--- a/yaksh/scripts/yaksh_script.sh
+++ b/yaksh/scripts/yaksh_script.sh
@@ -1,13 +1,10 @@
#!/bin/bash
# Basic script to install pip packages and run the yaksh code server command
-mkdir /sites/
-echo "** Copying online test directory **"
-cp -r /src/online_test /sites/online_test
-cd /sites/online_test
-echo "** Unmounting online test volume **"
-umount /src/online_test
+chown -R nobody output
+chmod -R a+rX data yaksh
+chmod -R o-w data yaksh
echo "** Installing python dependencies **"
-pip3 install -r /sites/online_test/requirements/requirements-codeserver.txt
+pip3 install -r ./requirements-codeserver.txt
echo "** Running code server **"
-python3 -m yaksh.code_server
+/usr/bin/sudo -su nobody python3 -m yaksh.code_server