From d8ae42ca071e0078001e580e1f92b1295b87698a Mon Sep 17 00:00:00 2001 From: virusdefender Date: Wed, 28 Sep 2016 19:55:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0docker=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 22 +++++++++++++++++++--- config.py | 7 ++++--- java_policy => deploy/java_policy | 0 deploy/sources.list | 10 ++++++++++ deploy/supervisord.conf | 20 ++++++++++++++++++++ docker-compose.example.yml | 10 ++++++++++ 6 files changed, 63 insertions(+), 6 deletions(-) rename java_policy => deploy/java_policy (100%) create mode 100644 deploy/sources.list create mode 100644 deploy/supervisord.conf create mode 100644 docker-compose.example.yml diff --git a/Dockerfile b/Dockerfile index 7a6334f..9d5b37c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,21 @@ -FROM judger -RUN apt-get update && apt-get install -y cmake vim -RUN cd /tmp && rm -rf Judger && git clone https://github.com/QingdaoU/Judger.git && cd Judger && git checkout newnew && mkdir build && cd build && cmake .. && make && make install && cd ../bindings/Python && python setup.py install +FROM ubuntu:14.04 +ENV DEBIAN_FRONTEND noninteractive +RUN rm /etc/apt/sources.list +COPY deploy/sources.list /etc/apt/ +RUN apt-get update +RUN apt-get -y install software-properties-common python-software-properties python python-dev gcc g++ git libtool python-pip libseccomp-dev cmake +RUN add-apt-repository -y ppa:webupd8team/java +RUN echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections +RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections +RUN apt-get update +RUN apt-get install -y oracle-java7-installer +RUN cd /tmp && git clone https://github.com/QingdaoU/Judger && cd Judger && git checkout newnew && mkdir build && cd build && cmake .. && make && make install && cd ../bindings/Python && python setup.py install RUN mkdir /var/wp RUN pip install psutil gunicorn web.py +RUN mkdir -p /judger_run /test_case /log /code +COPY deploy/java_policy /etc +COPY deploy/supervisord.conf /etc +RUN chmod -R 777 /judger_run +RUN pip install supervisor psutil gunicorn web.py +EXPOSE 8080 +CMD exec supervisord diff --git a/config.py b/config.py index c2ae92f..cd3a37a 100644 --- a/config.py +++ b/config.py @@ -5,10 +5,11 @@ import grp import os import pwd -JUDGER_WORKSPACE_BASE = "/var/wp" +JUDGER_WORKSPACE_BASE = "/judger_run" +LOG_BASE = "/log" -COMPILER_LOG_PATH = os.path.join(JUDGER_WORKSPACE_BASE, "compile.log") -JUDGER_RUN_LOG_PATH = os.path.join(JUDGER_WORKSPACE_BASE, "judger.log") +COMPILER_LOG_PATH = os.path.join(LOG_BASE, "compile.log") +JUDGER_RUN_LOG_PATH = os.path.join(LOG_BASE, "judger.log") LOW_PRIVILEDGE_UID = pwd.getpwnam("nobody").pw_uid LOW_PRIVILEDGE_GID = grp.getgrnam("nogroup").gr_gid diff --git a/java_policy b/deploy/java_policy similarity index 100% rename from java_policy rename to deploy/java_policy diff --git a/deploy/sources.list b/deploy/sources.list new file mode 100644 index 0000000..3f18a0f --- /dev/null +++ b/deploy/sources.list @@ -0,0 +1,10 @@ +deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse \ No newline at end of file diff --git a/deploy/supervisord.conf b/deploy/supervisord.conf new file mode 100644 index 0000000..7ade2fe --- /dev/null +++ b/deploy/supervisord.conf @@ -0,0 +1,20 @@ +[supervisord] +logfile=/log/judger_supervisord.log +logfile_maxbytes=50MB +logfile_backups=10 +loglevel=info +pidfile=/log/judger_supervisord.pid +nodaemon=true +childlogdir=/log/ + +[program:judger_server] +command=gunicorn -w 4 -b 0.0.0.0:8080 server:wsgiapp +directory=/code +numprocs=1 +stdout_logfile=/log/judger_server.log +stderr_logfile=/log/judger_server.log +autostart=true +autorestart=true +startsecs=5 +stopwaitsecs = 5 +killasgroup=true \ No newline at end of file diff --git a/docker-compose.example.yml b/docker-compose.example.yml new file mode 100644 index 0000000..7fb7c1e --- /dev/null +++ b/docker-compose.example.yml @@ -0,0 +1,10 @@ +judge_server: + image: judge_server + volumes: + - /data/test_case:/test_case + - /data/log:/log + - /data/JudgeServer:/code + environments: + - judger_token=PLEASE_REPLACE_TO_SECRET_TOKEN + ports: + - "0.0.0.0:11235:8080"