This commit is contained in:
Yutao Fang 2021-05-08 20:39:49 +08:00
parent d35d7333fe
commit c37356c687
4 changed files with 31 additions and 6 deletions

View File

@ -1,9 +1,14 @@
FROM ubuntu:18.04
COPY build/java_policy /etc
RUN buildDeps='software-properties-common git libtool cmake python-dev python3-pip python-pip libseccomp-dev' && \
apt-get update && apt-get install -y python python3 python-pkg-resources python3-pkg-resources gcc g++ $buildDeps && \
add-apt-repository ppa:openjdk-r/ppa && add-apt-repository ppa:longsleep/golang-backports && apt-get update && apt-get install -y golang-go openjdk-8-jdk && \
RUN export DEBIAN_FRONTEND=noninteractive && \
buildDeps='software-properties-common git libtool cmake python-dev python3-pip python-pip libseccomp-dev' && \
apt-get update && \
apt-get install -y tzdata python python3 python-pkg-resources python3-pkg-resources gcc g++ $buildDeps && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
add-apt-repository ppa:openjdk-r/ppa && add-apt-repository ppa:longsleep/golang-backports && add-apt-repository ppa:ondrej/php && \
apt-get update && apt-get install -y golang-go openjdk-8-jdk php-cli && \
pip3 install -I --no-cache-dir psutil gunicorn flask requests idna && \
cd /tmp && git clone -b newnew --depth 1 https://github.com/QingdaoU/Judger && cd Judger && \
mkdir build && cd build && cmake .. && make && make install && cd ../bindings/Python && python3 setup.py install && \
@ -11,6 +16,7 @@ RUN buildDeps='software-properties-common git libtool cmake python-dev python3-p
apt-get clean && rm -rf /var/lib/apt/lists/* && \
mkdir -p /code && \
useradd -u 12001 compiler && useradd -u 12002 code && useradd -u 12003 spj && usermod -a -G code spj
RUN echo -e 'opcache.enable=1\nopcache.enable_cli=1\nopcache.jit=1205\nopcache.jit_buffer_size=64M' > /etc/php/8.0/cli/conf.d/10-opcache-jit.ini
HEALTHCHECK --interval=5s --retries=3 CMD python3 /code/service.py
ADD server /code
WORKDIR /code

View File

@ -4,7 +4,7 @@ import json
import requests
from languages import c_lang_config, cpp_lang_config, java_lang_config, c_lang_spj_config, \
c_lang_spj_compile, py2_lang_config, py3_lang_config, go_lang_config
c_lang_spj_compile, py2_lang_config, py3_lang_config, go_lang_config, php_lang_config
class JudgeServerClientError(Exception):
@ -117,6 +117,10 @@ func main() {
fmt.Printf("%d", a + b)
}"""
php_src = """<?php
fscanf(STDIN, "%d %d", $a, $b);
print($a + $b);"""
client = JudgeServerClient(token=token, server_base_url="http://127.0.0.1:12358")
print("ping")
print(client.ping(), "\n\n")
@ -163,6 +167,11 @@ func main() {
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
test_case_id="normal", output=True), "\n\n")
print("php_judge")
print(client.judge(src=php_src, language_config=php_lang_config,
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
test_case_id="normal", output=True), "\n\n")
print("c_dynamic_input_judge")
print(client.judge(src=c_src, language_config=c_lang_config,
max_cpu_time=1000, max_memory=1024 * 1024 * 128,

View File

@ -110,7 +110,7 @@ go_lang_config = {
"max_real_time": 5000,
"max_memory": 1024 * 1024 * 1024,
"compile_command": "/usr/bin/go build -o {exe_path} {src_path}",
"env": ["GOCACHE=/tmp"]
"env": ["GOCACHE=/tmp", "GOPATH=/tmp/go"]
},
"run": {
"command": "{exe_path}",
@ -119,4 +119,13 @@ go_lang_config = {
"env": ["GODEBUG=madvdontneed=1", "GOCACHE=off"] + default_env,
"memory_limit_check_only": 1
}
}
php_lang_config = {
"run": {
"exe_name": "solution.php",
"command": "/usr/bin/php {exe_path}",
"seccomp_rule": "",
"env": default_env
}
}

View File

@ -4,6 +4,7 @@ import os
from config import COMPILER_LOG_PATH, COMPILER_USER_UID, COMPILER_GROUP_GID
from exception import CompileError
import shlex
class Compiler(object):
@ -12,7 +13,7 @@ class Compiler(object):
exe_path = os.path.join(output_dir, compile_config["exe_name"])
command = command.format(src_path=src_path, exe_dir=output_dir, exe_path=exe_path)
compiler_out = os.path.join(output_dir, "compiler.out")
_command = command.split(" ")
_command = shlex.split(command)
os.chdir(output_dir)
env = compile_config.get("env", [])