install: update Dockerfile and compose file (#999)

This commit is contained in:
Heran Yang authored and GitHub committed 2025-06-30 10:13:37 +01:00
1 parent 8ed74053d5
commit a49ff686e1
8 files changed
+104 -52

No files matched your search

+19 -24
View File
@@ -1,14 +1,13 @@
## 首要条件 ## 首要条件
## docker 安装方式仅适用于可熟练使用 docker-compose 维护容器的用户,并要求您有基础的错误排查能力 > [!WARNING]
## 该安装模块非官方维护,即不会提供任何技术支持 > docker 安装方式仅适用于可熟练使用 docker-compose 维护容器的用户,并要求您有基础的错误排查能力
## 普通用户请务必使用自动脚本安装,这可大大提高您一次成功的可能性 > 该安装模块非官方维护,即不会提供任何技术支持
> 普通用户请务必使用自动脚本安装,这可大大提高您一次成功的可能性
本文假设您已经安装了`Docker`、`docker-compose`、`git`。 本文假设您已经安装了 `docker`、`docker-compose`、`git`,**未安装请先安装**。
**未安装请先安装**。 ## 开始安装(请使用 Linux)
## 开始安装(不建议使用Windows)
1. 请选择磁盘空间富裕的位置,运行下面的命令。 1. 请选择磁盘空间富裕的位置,运行下面的命令。
@@ -18,32 +17,28 @@
`docker-compose up -d` `docker-compose up -d`
因为是在本机制作docker镜像,所以耗时可能会比较久。根据网速情况,大约5到30分钟就可以自动搭建完成,全程无需人工干预。 在本机制作 docker 镜像耗时可能会比较长。根据网络情况,大约 5 到 30 分钟就可以自动搭建完成,全程无需人工干预。
等命令执行完成,然后运行 `docker ps -a`,当看到所有的容器的状态没有`Exited (x) xxx`就代表 OJ 已经启动成功。 命令执行完成后运行 `docker ps -a`,当看到所有的容器的状态没有 `Exited (x) xxx` 就代表 OJ 已经启动成功。
## 注意 ## 注意
安装过程中,会默认注册一个超级管理员账号,用来做测评账号。用户名:`root`,密码:`rootroot`。**请务必及时修改密码**。修改该账号密码后,请修改`data/judge/config/judge.yaml`中的`password`。否则可能会无法测评。 安装过程中,会默认注册一个 uid 为 2 的测评账号。用户名:`judge`,密码:`examplepassword`。**请务必及时修改密码**。修改该账号密码后,请修改 `judge/judge.yaml` 中的 `password`。否则可能会无法测评。
## 测评机默认编译器 ## 测评机默认编译器
测评机默认安装了以下几个编译器,如有需要,请自行安装。 测评机默认安装了以下编译器,如有需要,请自行安装:
编译器列表:
1. gcc 1. gcc
2. python3 2. python3
3. g++ 3. g++
4. fp-compiler 4. fp-compiler
5. openjdk-8-jdk-headless 5. openjdk-17-jdk-headless
6. python 6. php-cli
7. php7.0-cli 7. rustc
8. rustc 8. ghc
9. haskell-platform 9. libjavascriptcoregtk-4.0-bin
10. libjavascriptcoregtk-4.0-bin 10. golang
11. golang 11. ruby
12. ruby 12. mono-runtime
13. mono-runtime 13. mono-mcs
14. mono-mcs
+7 -5
View File
@@ -1,6 +1,8 @@
FROM node:20 FROM node:20
ADD ./entrypoint.sh /root/entrypoint.sh
RUN yarn global add pm2 hydrooj @hydrooj/ui-default COPY ./entrypoint.sh /root/entrypoint.sh
RUN chmod +x /root/entrypoint.sh && \
mkdir -p /root/.hydro RUN yarn global add pm2 hydrooj @hydrooj/ui-default && \
ENTRYPOINT /root/entrypoint.sh chmod +x /root/entrypoint.sh
ENTRYPOINT ["/root/entrypoint.sh"]
+3 -2
View File
@@ -13,8 +13,9 @@ fi
if [ ! -f "$ROOT/first" ]; then if [ ! -f "$ROOT/first" ]; then
echo "for marking use only!" > "$ROOT/first" echo "for marking use only!" > "$ROOT/first"
hydrooj cli user create systemjudge@systemjudge.local root rootroot hydrooj cli user create systemjudge@systemjudge.local judge examplepassword 2
hydrooj cli user setSuperAdmin 2 hydrooj cli user setJudge 2
hydrooj cli system set server.host 0.0.0.0
fi fi
pm2-runtime start hydrooj pm2-runtime start hydrooj
+13 -6
View File
@@ -1,7 +1,4 @@
version: '3.7'
services: services:
# Warning: mongodb here is not password-protected. # Warning: mongodb here is not password-protected.
# DO NOT EXPOSE THIS SERVICE TO THE PUBLIC. # DO NOT EXPOSE THIS SERVICE TO THE PUBLIC.
oj-mongo: oj-mongo:
@@ -21,7 +18,14 @@ services:
- ./data/file:/data/file - ./data/file:/data/file
- ./data/backend:/root/.hydro - ./data/backend:/root/.hydro
ports: ports:
- "0.0.0.0:80:8888" # In docker mode, change THIS port instead of port in system settings! - "80:8888" # In docker mode, change THIS port instead of port in system settings!
healthcheck:
test: curl --silent --fail http://localhost:8888/status >/dev/null || exit 1
interval: 1m30s
timeout: 10s
retries: 3
start_period: 30s
start_interval: 5s
oj-judge: oj-judge:
build: ./judge build: ./judge
@@ -29,6 +33,9 @@ services:
restart: always restart: always
privileged: true privileged: true
depends_on: depends_on:
- oj-backend oj-backend:
condition: service_healthy
restart: true
volumes: volumes:
- ./data/judge:/root/.config/hydro - ./judge/judge.yaml:/root/.hydro/judge.yaml
- ./judge/mount.yaml:/root/.hydro/mount.yaml
+12 -11
View File
@@ -1,28 +1,29 @@
FROM node:20 FROM node:20
COPY ./entrypoint.sh /root/entrypoint.sh
RUN apt-get -qq update && \ RUN apt-get -qq update && \
apt-get install -y \ apt-get install -y \
gcc \ gcc \
python3 \ python3 \
g++ \ g++ \
fp-compiler \ fp-compiler \
openjdk-8-jdk-headless \ openjdk-17-jdk-headless \
python \ php-cli \
php7.0-cli \
rustc \ rustc \
haskell-platform \ ghc \
libjavascriptcoregtk-4.0-bin \ libjavascriptcoregtk-4.0-bin \
golang \ golang \
ruby \ ruby \
mono-runtime \ mono-runtime \
mono-mcs mono-mcs && \
chmod +x /root/entrypoint.sh && \
ADD ./entrypoint.sh /root/entrypoint.sh # node is at /usr/local/bin but hydrojudge will find it at /usr/bin
ADD ./judge.yaml /root/judge.yaml # so make a symlink to it
RUN chmod +x /root/entrypoint.sh ln -s /usr/local/bin/node /usr/bin/node
RUN yarn global add pm2 @hydrooj/hydrojudge && \ RUN yarn global add pm2 @hydrooj/hydrojudge && \
wget https://github.com/criyle/go-judge/releases/download/v1.8.0/go-judge_1.8.0_linux_amd64 -O /usr/bin/sandbox && \ wget https://github.com/criyle/go-judge/releases/download/v1.9.4/go-judge_1.9.4_linux_amd64v3 -O /usr/bin/sandbox && \
chmod +x /usr/bin/sandbox chmod +x /usr/bin/sandbox
ENTRYPOINT /root/entrypoint.sh ENTRYPOINT ["/root/entrypoint.sh"]
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
pm2 start sandbox pm2 start sandbox -- -mount-conf /root/.hydro/mount.yaml
pm2-runtime start hydrojudge pm2-runtime start hydrojudge
+3 -3
View File
@@ -2,6 +2,6 @@ hosts:
localhost: localhost:
type: hydro type: hydro
server_url: http://oj-backend:8888/ server_url: http://oj-backend:8888/
uname: root uname: judge
password: rootroot password: examplepassword
detail: true detail: full
+46
View File
@@ -0,0 +1,46 @@
mount:
- type: bind
source: /bin
target: /bin
readonly: true
- type: bind
source: /lib
target: /lib
readonly: true
- type: bind
source: /lib64
target: /lib64
readonly: true
- type: bind
source: /usr
target: /usr
readonly: true
- type: bind
source: /etc
target: /etc
readonly: true
- type: bind
source: /var
target: /var
readonly: true
- type: bind
source: /dev/null
target: /dev/null
- type: bind
source: /dev/urandom
target: /dev/urandom
- type: bind
source: /dev/zero
target: /dev/zero
- type: tmpfs
target: /w
data: size=512m,nr_inodes=8k
- type: tmpfs
target: /tmp
data: size=512m,nr_inodes=8k
proc: true
workDir: /w
hostName: executor_server
domainName: executor_server
uid: 1536
gid: 1536