Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf

[*.y{,a}ml]
indent_style = space
indent_size = 2

[{Dockerfile,*.py,judge_client,*.{c,h}{pp,}}]
indent_style = space
indent_size = 4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
uoj_data/
.php-cs-fixer.cache
.config.local.php
shell.nix
73 changes: 48 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
uoj-db:
image: ghcr.io/universaloj/uoj-db:latest
Expand All @@ -13,27 +11,22 @@ services:
environment:
- MYSQL_DATABASE=app_uoj233
- MYSQL_ROOT_PASSWORD=root

uoj-judger:
image: ghcr.io/universaloj/uoj-judger:latest
build:
context: ./judger/
dockerfile: Dockerfile
container_name: uoj-judger
restart: always
stdin_open: true
tty: true
cap_add:
- SYS_PTRACE
volumes:
- ./uoj_data/judger/log:/opt/uoj_judger/log
environment:
- UOJ_PROTOCOL=http
- UOJ_HOST=uoj-web
- JUDGER_NAME=compose_judger
- JUDGER_PASSWORD=_judger_password_
- SOCKET_PORT=2333
- SOCKET_PASSWORD=_judger_socket_password_
healthcheck:
test:
[
"CMD",
"mysqladmin",
"ping",
"-h",
"localhost",
"-u",
"root",
"-p$$MYSQL_ROOT_PASSWORD",
]
interval: 5s
timeout: 3s
retries: 5
start_period: 30s

uoj-web:
image: ghcr.io/universaloj/uoj-web:latest
Expand All @@ -47,8 +40,8 @@ services:
cap_add:
- SYS_PTRACE
depends_on:
- uoj-db
- uoj-judger
uoj-db:
condition: service_healthy
volumes:
- ./uoj_data/web/data:/var/uoj_data
- ./uoj_data/web/storage:/opt/uoj/web/app/storage
Expand All @@ -68,3 +61,33 @@ services:
- SALT_2=_salt_2_
- SALT_3=_salt_3_
- UOJ_PROTOCOL=http
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
interval: 5s
timeout: 3s
retries: 5
start_period: 30s

uoj-judger:
image: ghcr.io/universaloj/uoj-judger:latest
build:
context: ./judger/
dockerfile: Dockerfile
container_name: uoj-judger
restart: always
stdin_open: true
tty: true
cap_add:
- SYS_PTRACE
depends_on:
uoj-web:
condition: service_healthy
volumes:
- ./uoj_data/judger/log:/opt/uoj_judger/log
environment:
- UOJ_PROTOCOL=http
- UOJ_HOST=uoj-web
- JUDGER_NAME=compose_judger
- JUDGER_PASSWORD=_judger_password_
- SOCKET_PORT=2333
- SOCKET_PASSWORD=_judger_socket_password_
19 changes: 19 additions & 0 deletions judger/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.conf.json
log/*
!/log/.gitkeep
uoj_judger/builtin/checker/*
!uoj_judger/builtin/checker/*.cpp
!uoj_judger/builtin/checker/*.h
uoj_judger/builtin/judger/*
!uoj_judger/builtin/judger/*.cpp
!uoj_judger/builtin/judger/*.h
uoj_judger/data
uoj_judger/main_judger
uoj_judger/run/*
!uoj_judger/run/*.cpp
!uoj_judger/run/*.h
uoj_judger/work/*
uoj_judger/result/*
!uoj_judger/work/.gitkeep
!uoj_judger/result/.gitkeep

1 change: 0 additions & 1 deletion judger/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ uoj_judger/builtin/judger/*
!uoj_judger/builtin/judger/*.cpp
!uoj_judger/builtin/judger/*.h
uoj_judger/data
uoj_judger/include/uoj_work_path.h
uoj_judger/main_judger
uoj_judger/run/*
!uoj_judger/run/*.cpp
Expand Down
50 changes: 31 additions & 19 deletions judger/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
FROM ubuntu:20.04
FROM ubuntu:24.04
MAINTAINER Baoshuo <[email protected]>
LABEL org.opencontainers.image.source=https://github.com/UniversalOJ/UOJ-System

LABEL org.opencontainers.image.source="https://github.com/UniversalOJ/UOJ-System"
LABEL org.opencontainers.image.description="UOJ Judger"
LABEL org.opencontainers.image.licenses=MIT
LABEL org.opencontainers.image.licenses="MIT"

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

ENV DEBIAN_FRONTEND=noninteractive
ARG CLONE_ADDFLAG
ENV LANG=C.UTF-8
ENV TZ=Asia/Shanghai

RUN apt-get update && \
apt-get install -y --no-install-recommends gnupg ca-certificates apt-transport-https && \
RUN \
apt-get update && \
for pkg in git vim ntp zip unzip curl wget build-essential fp-compiler python python3 python3-requests openjdk-8-jdk openjdk-11-jdk tzdata; do \
cnt=10 && \
while ! apt-get install -y "$pkg"; do \
if [ $cnt -le 0 ]; then \
echo "Failed to install $pkg" && \
exit 1; \
fi; \
cnt=$((cnt - 1)); \
done; \
done
apt-get install -y --no-install-recommends \
git vim ntp zip unzip curl wget make dpkg-dev ca-certificates \
fp-compiler \
python3 python3-requests \
openjdk-21-jdk-headless \
gcc-14 g++-14 \
libseccomp-dev \
tzdata && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 && \
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-14 100 && \
cd /usr/src && \
wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz && \
tar xzf Python-2.7.18.tgz && \
cd Python-2.7.18 && \
./configure && \
make -j"$(nproc)" && \
make install && \
cd / && \
rm -rf /usr/src/Python-2.7.18.tgz /usr/src/Python-2.7.18 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ADD . /opt/uoj_judger
WORKDIR /opt/uoj_judger

# Install environment and set startup script
RUN sh install.sh -p && sh install.sh -d

ENV LANG=C.UTF-8 TZ=Asia/Shanghai
EXPOSE 2333
CMD /opt/up
CMD ["/opt/up"]
14 changes: 4 additions & 10 deletions judger/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ UOJEOF
#Add judger user
adduser judger --gecos "" --disabled-password
#Set uoj_data path
mkdir /var/uoj_data_copy && chown judger /var/uoj_data_copy
mkdir /var/uoj_data_copy && chown judger:judger /var/uoj_data_copy
#Compile uoj_judger and set runtime
chown -R judger:judger /opt/uoj_judger
su judger <<EOD
ln -s /var/uoj_data_copy /opt/uoj_judger/uoj_judger/data
cd /opt/uoj_judger && chmod +x judge_client
cat >uoj_judger/include/uoj_work_path.h <<UOJEOF
#define UOJ_WORK_PATH "/opt/uoj_judger/uoj_judger"
#define UOJ_JUDGER_BASESYSTEM_UBUNTU1804
#define UOJ_JUDGER_PYTHON3_VERSION "3.8"
#define UOJ_JUDGER_FPC_VERSION "3.0.4"
UOJEOF
cd uoj_judger && make -j$(($(nproc) + 1))
EOD
}
Expand All @@ -48,10 +42,10 @@ initProgress(){
"socket_password": "$SOCKET_PASSWORD"
}
UOJEOF
chmod 600 .conf.json && chown judger .conf.json
chmod 600 .conf.json && chown judger:judger .conf.json
chown -R judger:judger ./log
#Start services
service ntp restart
service ntpd restart
su judger -c '/opt/uoj_judger/judge_client start'
echo "please modify the database after getting the judger server ready:"
echo "insert into judger_info (judger_name, password, ip) values ('$JUDGER_NAME', '$JUDGER_PASSWORD', '__judger_ip_here__');"
Expand All @@ -68,7 +62,7 @@ dockerPrep(){
if [ ! -f \"/opt/uoj_judger/.conf.json\" ]; then
cd /opt/uoj_judger && sh install.sh -i
fi
service ntp start
service ntpd start
su judger -c \"/opt/uoj_judger/judge_client start\"
exec bash" >/opt/up
chmod +x /opt/up
Expand Down
Loading