Skip to content
simplefanC edited this page May 12, 2024 · 3 revisions

判题服务部署

VOJ使用安全沙盒的是开源的go-judge,具体使用可看该项目文档。

注意:判题服务可以部署多台云服务器,步骤一样

前言

下载打包所需文件

git clone https://github.com/simplefanc/voj-deploy.git && cd voj-deploy/src/judger

当前文件夹为打包[voj-judger](https://github.com/simplefanC/voj/tree/main/voj-judger)镜像的相关文件,然后打包voj-judger(SpringBoot项目)成jar包也放到当前文件夹,之后执行以下命令进行打包成镜像.

docker build -t voj-judger .

docker-compose 启动

version: "3"
services:
  voj-judger:
    # image: registry.cn-shanghai.aliyuncs.com/simplefanc/voj_judger
    image: voj-judger
    container_name: voj-judger
    restart: always
    volumes:
      - ./judge/testcase:/judge/testcase
      - ./judge/log:/judge/log
      - ./judge/run:/judge/run
      - ./judge/spj:/judge/spj
      - ./judge/interactive:/judge/interactive
    environment:
      - TZ=Asia/Shanghai
      - JUDGE_SERVER_IP=your_judgeserver_ip # 服务器公网ip
      - JUDGE_SERVER_PORT=8088
      - JUDGE_SERVER_NAME=judger-1 # 判题服务的名称,最好每个判题机不一样
      - NACOS_URL=172.20.0.4:8848  # nacos所在服务的ip:port
      - NACOS_USERNAME=nacos  # 分布式需要修正nacos账号密码
      - NACOS_PASSWORD=nacos
      - MAX_TASK_NUM=-1 # -1表示最大可接收判题任务数为cpu核心数+1
      - REMOTE_JUDGE_OPEN=true # 当前判题服务器是否开启远程虚拟判题功能
      - REMOTE_JUDGE_MAX_TASK_NUM=-1 # -1表示最大可接收远程判题任务数为cpu核心数*2+1
      - PARALLEL_TASK=default # 默认沙盒并行判题程序数为cpu核心数
    ports:
      - 8088:8088
      # - "0.0.0.0:5050:5050" # 一般不开放安全沙盒端口
    shm_size: 512mb
    privileged: true # 设置容器的权限为root
Clone this wiki locally