Skip to content

Commit

Permalink
ジャッジアップデート (#138)
Browse files Browse the repository at this point in the history
* [Update] judge image
Dockerfileの言語を更新しました

それに伴い、フロントエンドの言語表示も対応させました。

ライブラリなどはAtCoderを参考にしています

**run.go**
実行時に環境変数`PATH`を設定するようにしました。これが無いことが原因で一部言語が動かなかったためです。

* [fix] disable --with-lto
  • Loading branch information
ocha98 authored Jan 22, 2024
1 parent e6db3d7 commit 6205303
Show file tree
Hide file tree
Showing 13 changed files with 1,094 additions and 338 deletions.
156 changes: 127 additions & 29 deletions mojacoder-backend/judge-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,137 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

SHELL ["/bin/bash", "-c"]

ENV DEBIAN_FRONTEND noninteractive
RUN apt update -y
RUN apt install -y gnupg ca-certificates
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list
RUN apt update

RUN apt install -y software-properties-common
RUN add-apt-repository ppa:longsleep/golang-backports
RUN apt update
RUN apt install -y golang-1.21-go

WORKDIR /tmp

# golang 1.21
RUN apt install -y software-properties-common && \
add-apt-repository ppa:longsleep/golang-backports && \
apt update && \
apt install -y golang-1.21-go
ENV PATH $PATH:/usr/lib/go-1.21/bin

RUN apt install -y python3.8 build-essential mono-devel bf cargo pypy3 ruby2.7 default-jdk sbcl
# C/C++ GCC12 Boost(1.84.0) Eigen(3.4.0) GMP(6.3.0) AC-Library(1.5.1)
RUN apt install -y g++-12 gcc-12 build-essential m4 wget unzip && \
wget https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.tar.gz && \
tar -zxf boost_1_84_0.tar.gz && \
cd boost_1_84_0 && \
./bootstrap.sh --without-libraries=mpi,graph_parallel && \
./b2 -j4 toolset=gcc variant=release link=static runtime-link=static cxxflags="-std=gnu++23" stage && \
./b2 -j4 toolset=gcc variant=release link=static runtime-link=static cxxflags="-std=gnu++23" install && \
cd /tmp && \
wget https://github.com/atcoder/ac-library/releases/download/v1.5.1/ac-library.zip && \
mkdir ac-library && \
unzip ./ac-library.zip -d ./ac-library && \
mv ./ac-library/atcoder /usr/local/include/ && \
wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz && \
tar -xf gmp-6.3.0.tar.xz && \
cd gmp-6.3.0 && \
./configure && \
make && \
make install && \
cd /tmp && \
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz && \
tar -zxf eigen-3.4.0.tar.gz && \
mv ./eigen-3.4.0/Eigen /usr/local/include/ && \
rm -rf /tmp/*

WORKDIR /tmp
RUN apt install -y wget curl zip
RUN wget http://www.jsoftware.com/download/j902/install/j902_amd64.deb
RUN mkdir -p /usr/share/icons/hicolor/scalable/apps/
RUN dpkg -i j902_amd64.deb
RUN echo -e "load 'pacman'\n'update' jpkg ''\n'install' jpkg 'dev/fold'\n" | ijconsole
RUN curl -s https://get.sdkman.io | bash && source ~/.sdkman/bin/sdkman-init.sh && sdk install kotlin
RUN wget https://github.com/atcoder/ac-library/archive/master.zip
RUN unzip ./master.zip
RUN mv ./ac-library-master/atcoder /usr/local/include/
RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.zip
RUN unzip ./boost_1_76_0.zip
RUN mv ./boost_1_76_0/boost /usr/local/include/

RUN apt install -y python3-pip
RUN pip3 install numpy
RUN pypy3 -m pip install numpy
# Python 3.11
COPY python_requirements.txt .
RUN apt install -y build-essential libbz2-dev libdb-dev git \
libreadline-dev libffi-dev libgdbm-dev liblzma-dev \
libncursesw5-dev libsqlite3-dev libssl-dev \
zlib1g-dev uuid-dev && \
wget https://www.python.org/ftp/python/3.11.6/Python-3.11.6.tar.xz && \
tar -xf Python-3.11.6.tar.xz && \
cd Python-3.11.6 && \
./configure --enable-optimizations && \
make -j4 && \
make altinstall && \
cd /tmp && \
python3.11 -m pip install -r python_requirements.txt && \
rm -rf /tmp/*

# PyPy 3.10-v7.3.13
COPY pypy_requirements.txt .
RUN apt install libgeos-dev -y && \
wget https://downloads.python.org/pypy/pypy3.10-v7.3.13-linux64.tar.bz2 && \
tar -xf pypy3.10-v7.3.13-linux64.tar.bz2 -C /usr/local && \
/usr/local/pypy3.10-v7.3.13-linux64/bin/pypy3 -m ensurepip && \
/usr/local/pypy3.10-v7.3.13-linux64/bin/pypy3 -m pip install -U pip wheel && \
/usr/local/pypy3.10-v7.3.13-linux64/bin/pypy3 -m pip install -r pypy_requirements.txt && \
rm -rf /tmp/*
ENV PATH $PATH:/usr/local/pypy3.10-v7.3.13-linux64/bin

# java openjdk-21 ac-library-java-1.0.0
RUN wget https://download.java.net/java/GA/jdk21.0.1/415e3f918a1f4062a0074a2794853d0d/12/GPL/openjdk-21.0.1_linux-x64_bin.tar.gz && \
mkdir -p /usr/local/java && \
tar -xzf openjdk-21.0.1_linux-x64_bin.tar.gz -C /usr/local/java && \
export JAVA_HOME=/usr/local/java/jdk-21.0.1 && \
export PATH=$JAVA_HOME/bin:$PATH && \
mkdir -p /usr/local/ac-library-java && \
wget https://github.com/ocha98/ac-library-java/archive/refs/tags/1.0.0.tar.gz && \
tar -xzf 1.0.0.tar.gz && \
cd ac-library-java-1.0.0 && \
chmod +x builder.sh && ./builder.sh && \
cp ./src/bin/ac_library.jar /usr/local/ac-library-java/ac_library.jar && \
cd /tmp && \
rm -rf /tmp/*
ENV JAVA_HOME /usr/local/java/jdk-21.0.1
ENV PATH $PATH:$JAVA_HOME/bin

# Kotlin 1.9.21
RUN apt install -y curl zip && \
curl -s https://get.sdkman.io | bash && \
source ~/.sdkman/bin/sdkman-init.sh && \
sdk install kotlin 1.9.21 && \
rm -rf /tmp/*

# bf 20041219
RUN apt install -y bf

# Nim 1.6.16
RUN curl https://nim-lang.org/choosenim/init.sh -sSf -o init.sh && \
sh init.sh -y && \
export PATH=/root/.nimble/bin:$PATH && \
choosenim 1.6.16 && \
nimble install neo -y && \
apt install -y libopenblas-base -y && \
nimble install https://github.com/zer0-star/Nim-ACL && \
nimble install bignum -y && \
rm -rf /tmp/*
ENV PATH $PATH:/root/.nimble/bin

# Rust 1.75.0
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
/root/.cargo/bin/rustup default 1.75.0 && \
export PATH=$PATH:/root/.cargo/bin && \
cargo install --git https://github.com/rust-lang-ja/atcoder-rustc-dep-option-generator.git && \
rm -rf /tmp/*
ENV PATH $PATH:/root/.cargo/bin

# Ruby 3.2.2
RUN apt install -y bison libreadline6-dev libncurses5-dev build-essential libssl-dev libyaml-dev zlib1g-dev libffi-dev libgmp-dev libreadline-dev && \
wget https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz && \
tar -xzf ruby-3.2.2.tar.gz && \
cd ruby-3.2.2 && \
./configure && \
make install && \
gem install rbtree ac-library-rb faster_prime sorted_set numo-narray && \
cd /tmp && \
rm -rf /tmp/*

# Common Lisp 2.1.11
RUN apt install -y sbcl

# C# mono6.12.0
RUN apt install -y gnupg ca-certificates && \
gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal/snapshots/6.12.0 main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt update && \
apt install -y mono-devel

RUN groupadd -r -g 400 code && useradd -r -u 400 -g 400 code

Expand Down
58 changes: 31 additions & 27 deletions mojacoder-backend/judge-image/language-definition.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,77 @@
{
"go-1.14": {
"name": "Go (1.14)",
"go-1.21": {
"name": "Go (1.21)",
"filename": "main.go",
"compileCommand": "go build main.go",
"runCommand": "./main"
},
"python3.8": {
"name": "Python 3.8",
"python3.11": {
"name": "Python 3.11",
"filename": "main.py",
"runCommand": "python3.8 ./main.py"
"compileCommand": "python3.11 -m py_compile main.py",
"runCommand": "python3.11 ./main.py"
},
"gcc-9.3.0": {
"gcc-12.3": {
"filename": "main.c",
"compileCommand": "gcc -std=gnu11 -O2 -DONLINE_JUDGE -lm main.c",
"compileCommand": "gcc-12 -std=gnu17 -O2 -DONLINE_JUDGE -lm main.c",
"runCommand": "./a.out"
},
"g++-9.3.0": {
"g++-12.3": {
"filename": "main.cpp",
"compileCommand": "g++ -std=gnu++17 -Wall -Wextra -O2 -DONLINE_JUDGE main.cpp",
"compileCommand": "g++-12 -std=gnu++23 -Wall -Wextra -O2 -DONLINE_JUDGE main.cpp",
"runCommand": "./a.out"
},
"csharp-mono-csc-3.6.0": {
"csharp-mono-csc-3.9.0": {
"filename": "main.cs",
"compileCommand": "csc main.cs",
"runCommand": "mono main.exe"
},
"csharp-mono-mcs-6.12.0.107": {
"csharp-mono-mcs-6.12.0": {
"filename": "main.cs",
"compileCommand": "mcs main.cs",
"runCommand": "mono main.exe"
},
"bf-20041219": {
"filename": "main.bf",
"runCommand": "bf main.bf"
"runCommand": "bf -c999999999 main.bf"
},
"cat": {
"filename": "main.txt",
"runCommand": "cat main.txt"
},
"rust-1.43.0": {
"rust-1.74.0": {
"filename": "main.rs",
"compileCommand": "RUST_LIB=/usr/src/app/rust/target/release/deps/ rustc --edition=2018 -C opt-level=3 $(/usr/src/app/rust/rustc-dep-option-generator --manifest-path /usr/src/app/rust/Cargo.toml) main.rs",
"compileCommand": "mv main.rs /usr/src/app/rust/src/main.rs && ( cd /usr/src/app/rust && cargo build --release --offline && rm src/main.rs ) && cp /usr/src/app/rust/target/release/rust main",
"runCommand": "./main"
},
"pypy3-7.3.1": {
"pypy3-7.3.13": {
"filename": "main.py",
"runCommand": "pypy3 main.py"
"runCommand": "pypy3 main.py",
"compileCommand": "pypy3 -m py_compile main.py"
},
"ruby-2.7": {
"ruby-3.2.2": {
"filename": "main.rb",
"runCommand": "ruby main.rb"
"runCommand": "ruby main.rb",
"compileCommand": "ruby -c main.rb"
},
"java-11": {
"java-21": {
"filename": "Main.java",
"compileCommand": "javac Main.java",
"runCommand": "java Main"
"compileCommand": "javac -cp /usr/local/ac-library-java/ac_library.jar Main.java",
"runCommand": "java -cp /usr/local/ac-library-java/ac_library.jar: Main"
},
"j-902": {
"filename": "main.ijs",
"runCommand": "ijconsole main.ijs"
},
"kotlin-1.4": {
"kotlin-1.9.21": {
"filename": "main.kt",
"compileCommand": "~root/.sdkman/candidates/kotlin/current/bin/kotlinc main.kt -include-runtime -d main.jar",
"runCommand": "java -jar main.jar"
},
"commonlisp-2.0": {
"commonlisp-2.1.11": {
"filename": "main.lisp",
"compileCommand": "sbcl --noinform --eval \"(compile-file \\\"main.lisp\\\")\" --quit",
"runCommand": "sbcl --script main.fasl"
},
"nim-1.6.16": {
"filename": "Main.nim",
"compileCommand": "nim cpp -d:release --opt:speed --multimethods:on --warning[SmallLshouldNotBeUsed]:off --hints:off -o:a.out Main.nim ",
"runCommand": "./a.out"
}
}
11 changes: 11 additions & 0 deletions mojacoder-backend/judge-image/pypy_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
numpy==1.26.2
networkx==3.2.1
sympy==1.12
sortedcontainers==2.4.0
more-itertools==10.1.0
shapely==2.0.2
bitarray==2.8.3
mpmath==1.3.0
z3-solver==4.12.2.0
cppyy==3.1.2
git+https://github.com/not522/ac-library-python
12 changes: 12 additions & 0 deletions mojacoder-backend/judge-image/python_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
numpy==1.26.2
networkx==3.2.1
sympy==1.12
sortedcontainers==2.4.0
more-itertools==10.1.0
shapely==2.0.2
bitarray==2.8.3
mpmath==1.3.0
z3-solver==4.12.2.0
cppyy==3.1.2
numba==0.58.1
git+https://github.com/not522/ac-library-python
5 changes: 4 additions & 1 deletion mojacoder-backend/judge-image/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"io"
"os"
"os/exec"
"strings"
"syscall"
Expand Down Expand Up @@ -42,7 +43,9 @@ func run(definition LanguageDefinition, config RunConfig) (RunResult, error) {
args := strings.Join(config.runCommandArgs, " ")
command := fmt.Sprintf("ulimit -u 32 -m %d && timeout --preserve-status -sSIGKILL %d %s %s; EXIT_CODE=$?; kill -SIGKILL -1; wait; exit $EXIT_CODE", config.memoryLimit+additional_memory, config.timeLimit, definition.RunCommand, args)
cmd := exec.Command("bash", "-c", command)
cmd.Env = []string{}
cmd.Env = []string{
"PATH=" + os.Getenv("PATH"),
}
cmd.Dir = config.dir
cmd.Stdin = config.stdin
cmd.Stdout = config.stdout
Expand Down
Loading

0 comments on commit 6205303

Please sign in to comment.