Merge branch 'master' into 18.04

This commit is contained in:
Harry-zklcdc 2020-07-17 09:48:27 +08:00
commit c40402a9f2
5 changed files with 57 additions and 20 deletions

View File

@ -1,22 +1,21 @@
FROM ubuntu:18.04
COPY build/java_policy /etc
COPY sources.list /etc/apt/sources.list
RUN buildDeps='software-properties-common git libtool cmake python-dev python3-pip python-pip libseccomp-dev' && \
apt-get update && apt-get install -y python python-pkg-resources python3-pkg-resources openjdk-8-jdk $buildDeps && apt-get remove python3-idna -y && \
pip3 install --no-cache-dir psutil gunicorn flask requests idna -i https://mirrors.aliyun.com/pypi/simple/ && \
cd /tmp && git clone -b newnew --depth 1 https://github.com/Harry-zklcdc/Judger && cd Judger && \
apt-get update && apt-get install -y python python3 python-pkg-resources python3-pkg-resources $buildDeps && \
add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update && apt-get install -y gcc-9 g++-9 && \
rm /usr/bin/gcc /usr/bin/g++ && ln -s /usr/bin/gcc-9 /usr/bin/gcc && ln -s /usr/bin/g++-9 /usr/bin/g++ && \
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 && \
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 && \
apt-get purge -y --auto-remove wget $buildDeps && \
apt-get install -y gcc-8 g++-8 && ln -s /usr/bin/gcc-8 /usr/bin/gcc && ln -s /usr/bin/g++-8 /usr/bin/g++ && \
apt-get purge -y --auto-remove $buildDeps && \
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
HEALTHCHECK --interval=5s --retries=3 CMD python3 /code/service.py
ADD server /code
WORKDIR /code
RUN gcc -shared -fPIC -o unbuffer.so unbuffer.c
EXPOSE 8080
ENTRYPOINT /code/entrypoint.sh
ENTRYPOINT /code/entrypoint.sh

View File

@ -2,15 +2,17 @@ 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 python-pkg-resources python3-pkg-resources gcc-8 g++-8 openjdk-8-jdk $buildDeps && apt-get remove python3-idna -y && \
rm /usr/bin/gcc /usr/bin/g++ && ln -s /usr/bin/gcc-8 /usr/bin/gcc && ln -s /usr/bin/g++-8 /usr/bin/g++ && \
pip3 install --no-cache-dir psutil gunicorn flask requests idna -i https://mirrors.aliyun.com/pypi/simple/ && \
RUN apt-get update && apt-get install -y wget && wget https://raw.githubusercontent.com/Harry-zklcdc/JudgeServer/master/sources.list && mv sources.list /etc/apt/sources.list && \
buildDeps='software-properties-common git libtool cmake python-dev python3-pip python-pip libseccomp-dev' && \
apt-get update && apt-get install -y python python-pkg-resources python3-pkg-resources $buildDeps && \
add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update && apt-get install -y gcc-9 g++-9 && \
rm /usr/bin/gcc /usr/bin/g++ && ln -s /usr/bin/gcc-9 /usr/bin/gcc && ln -s /usr/bin/g++-9 /usr/bin/g++ && \
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 && \
pip3 install -I --no-cache-dir psutil gunicorn flask requests idna -i https://mirrors.aliyun.com/pypi/simple/ && \
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 && \
apt-get purge -y --auto-remove wget $buildDeps && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
ln -s /usr/bin/gcc-8 /usr/bin/gcc && ln -s /usr/bin/g++-8 /usr/bin/g++ && \
mkdir -p /code && \
useradd -u 12001 compiler && useradd -u 12002 code && useradd -u 12003 spj && usermod -a -G code spj

View File

@ -4,7 +4,7 @@ import json
import requests
from client.Python.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
c_lang_spj_compile, py2_lang_config, py3_lang_config, go_lang_config
class JudgeServerClientError(Exception):
@ -107,6 +107,16 @@ print int(s1[0]) + int(s1[1])"""
s1 = s.split(" ")
print(int(s1[0]) + int(s1[1]))"""
go_src = """package main
import "fmt"
func main() {
a := 0
b := 0
fmt.Scanf("%d %d", &a, &b)
fmt.Printf("%d", a + b)
}"""
client = JudgeServerClient(token=token, server_base_url="http://127.0.0.1:12358")
print("ping")
print(client.ping(), "\n\n")
@ -141,12 +151,17 @@ print(int(s1[0]) + int(s1[1]))"""
print("py2_judge")
print(client.judge(src=py2_src, language_config=py2_lang_config,
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
test_case_id="normal"), "\n\n")
test_case_id="normal", output=True), "\n\n")
print("py3_judge")
print(client.judge(src=py3_src, language_config=py3_lang_config,
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
test_case_id="normal"), "\n\n")
test_case_id="normal", output=True), "\n\n")
print("go_judge")
print(client.judge(src=go_src, language_config=go_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,

View File

@ -89,7 +89,7 @@ py2_lang_config = {
py3_lang_config = {
"compile": {
"src_name": "solution.py",
"exe_name": "__pycache__/solution.cpython-35.pyc",
"exe_name": "__pycache__/solution.cpython-36.pyc",
"max_cpu_time": 3000,
"max_real_time": 5000,
"max_memory": 128 * 1024 * 1024,
@ -101,3 +101,22 @@ py3_lang_config = {
"env": ["PYTHONIOENCODING=UTF-8"] + default_env
}
}
go_lang_config = {
"compile": {
"src_name": "main.go",
"exe_name": "main",
"max_cpu_time": 3000,
"max_real_time": 5000,
"max_memory": 1024 * 1024 * 1024,
"compile_command": "/usr/bin/go build -o {exe_path} {src_path}",
"env": ["GOCACHE=/tmp"]
},
"run": {
"command": "{exe_path}",
"seccomp_rule": "",
# 降低内存占用
"env": ["GODEBUG=madvdontneed=1", "GOCACHE=off"] + default_env,
"memory_limit_check_only": 1
}
}

View File

@ -15,11 +15,13 @@ class Compiler(object):
_command = command.split(" ")
os.chdir(output_dir)
env = compile_config.get("env", [])
env.append("PATH=" + os.getenv("PATH"))
result = _judger.run(max_cpu_time=compile_config["max_cpu_time"],
max_real_time=compile_config["max_real_time"],
max_memory=compile_config["max_memory"],
max_stack=128 * 1024 * 1024,
max_output_size=1024 * 1024,
max_output_size=20 * 1024 * 1024,
max_process_number=_judger.UNLIMITED,
exe_path=_command[0],
# /dev/null is best, but in some system, this will call ioctl system call
@ -27,7 +29,7 @@ class Compiler(object):
output_path=compiler_out,
error_path=compiler_out,
args=_command[1::],
env=["PATH=" + os.getenv("PATH")],
env=env,
log_path=COMPILER_LOG_PATH,
seccomp_rule_name=None,
uid=COMPILER_USER_UID,