Hosting the Backend of Online Judge
Create a new user named oj_main and add it to sudo group
sudo adduser oj_main
sudo usermod -aG sudo oj_main
su oj_main
Clone the Online-Judge github repo in the home directory
git clone https://github.com/lugnitdgp/Online-Judge.git
Create install.sh in the home directory and add the following into it
sudo apt-get remove docker docker-engine docker.io containerd runc -y
sudo apt-get update -y
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update -y
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose -y
Run and install the docker and docker-compose using install.sh
sudo chmod +x install.sh
./install.sh
Copy the .env.example file into .env file and add your credentials
cd Online-Judge/
cp .env.example .env
nano .env
Run the docker containers using the docker-compose command
sudo docker-compose -f docker-compose.prod.yml up -d
Create a new user named oj_executor and add it to sudo group
sudo adduser oj_executor
sudo usermod -aG sudo oj_executor
su oj_executor
Create install.sh in the home directory and add the following into it
sudo apt-get remove docker docker-engine docker.io containerd runc -y
sudo apt-get update -y
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update -y
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose -y
Run and install the docker and docker-compose using install.sh
sudo chmod +x install.sh
./install.sh
copy the .env.example file into .env file and make the necessary changes
cd OJ_CodeExecutor/
cp .env.example .env
cd OJExec-Python
cp .env.example .env
Run the following commands to create the worker nodes
sudo docker swarm init --advertise-addr OJ_backend_ip
sudo docker login
sudo docker service create --name registry --publish published=5000,target=5000 registry:2
Run the docker containers using the docker-compose command
cd ..
sudo docker-compose -f docker-compose.prod.yml build
sudo docker-compose -f docker-compose.prod.yml push
To start the service using image we uploaded
sudo docker stack deploy -c docker-compose.prod.yml executor
Set the scale of worker nodes
sudo docker service scale executor_executor=5
To stop all the worker nodes
sudo docker stack rm executor