Skip to content

dAiv-CNU/OnlineJudgeDeploy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Online Judge Deploy Setting

Main modules are available below:

Environmental preparation (Linux)

  • System: Ubuntu 18.04 LTS
  1. Install the necessary dependencies

    sudo apt-get update
    sudo apt-get install -y vim python3-pip curl git
    sudo pip3 install --upgrade pip
    sudo pip3 install docker-compose
  2. Install Docker

    Install using script: sudo curl -sSL get.docker.com | sh

    Other installation methods: https://docs.docker.com/install/

Install

  1. Please select a location with some surplus disk space and run the following command:

    git clone -b 2.0 https://github.com/dAiv-CNU/OnlineJudgeDeploy.git deploy
    sudo ln -rs deploy ./Desktop/deploy
    cd deploy
  2. Build custom docker images (if needed)

    git clone https://github.com/dAiv-CNU/OnlineJudge.git backend
    sudo docker buildx build ./backend -t oj-image/backend --load
  3. Start service containers

    sudo docker compose up -d
  4. Check status

    sudo docker ps -a

According to the network speed, the setup can be completed automatically in about 5 to 30 minutes without manual intervention.

Wait for the command execution to complete, and then run docker ps -a. When you see that the status of all the containers does not have unhealthy or Exited (x) xxx, it means OnlineJudge has started successfully.

Access the server's HTTP 80 port or HTTPS 443 port through a browser, and you can start using it. The background management path is /admin, the super administrator user name automatically added during the installation process is root, and the password is rootroot. If you log in successfully, please change your account password immediately..

Don't forget to read the documentation: http://opensource.qduoj.com/

Build Nginx

  1. Download the Nginx installation package

    wget 'http://nginx.org/download/nginx-1.22.1.tar.gz'
    tar -xzvf nginx-1.22.1.tar.gz
    rm *.tar.gz
    cd nginx-1.22.1
    wget 'https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.37.tar.gz'
    tar -xzvf v0.37.tar.gz
  2. Build and Install

    sudo apt-get install -y libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev
    ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --add-module=./headers-more-nginx-module-0.37
    make
    sudo make install
    /usr/local/nginx/sbin/nginx -V
    sudo ln -s /etc/nginx/nginx.conf /usr/local/nginx/conf/nginx.conf
    sudo ln -s /usr/local/nginx/sbin/nginx /sbin/nginx
  3. Clean up build files

    cd ..
    rm -rf nginx-1.22.1

SSL Configuration

  1. Install Certbot

    sudo apt-get install letsencrypt -y
  2. Shutdown Global/Docker System Nginx

    sudo service nginx stop
    sudo docker compose down
  3. Obtain SSL Certificate

    sudo certbot certonly --standalone -d daiv.ddns.net
    sudo cat /etc/letsencrypt/live/daiv.ddns.net/fullchain.pem
  4. Add SSL Settings to Nginx Config

    sudo cp ./nginx/default /etc/nginx/sites-available/default
  5. Restart Nginx

    sudo nginx -t
    sudo service nginx restart
    sudo docker compose up -d
  6. Add a scheduled task to renew the certificate

    sudo chmod +x cert_renew.sh
    sudo crontab -e
    • add the following line to the file
    30 4 * * 0 /home/daiv/deploy/cert_renew.sh
    
    • restart cron service
    sudo service cron start

Uninstall

  1. Stop service containers

    sudo docker compose down
  2. Delete all docker containers and images

    sudo docker stop $(sudo docker ps -a -q)
    sudo docker rm $(sudo docker ps -a -q)
    sudo docker rmi $(sudo docker images -q)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%