Installing Judge0 CE on OpenSUSE Latest

Judge0 CE is a free and open-source online code execution (OCE) system that allows you to compile, execute, and grade code submitted by users in various programming languages. It can be deployed locally, and this tutorial will guide you on how to install it on OpenSUSE Latest.

Prerequisites

Before proceeding, ensure that the following prerequisites are installed on your system:

You can install Git, Docker, and Docker Compose using OpenSUSE's package manager.

Step 1: Clone the Repository

Clone the Judge0 CE repository from GitHub by running the following command in your terminal:

git clone https://github.com/judge0/judge0.git

Once the clone is completed, switch to the newly created judge0 directory using the command:

cd judge0

Step 2: Configure the Environment Variables

Judge0 CE requires some environment variables to be set to enable its operation fully. You can create a .env file in the judge0 directory and set the required variables using your preferred text editor.

An example .env file can be created by copying the example.env file in the judge0 directory and renaming it.

cp example.env .env

In the .env file, you will see the following variables:

DATABASE_URL=postgresql://judge0:password@db:5432/judge0
SECRET_KEY_BASE=
RAILS_LOG_TO_STDOUT=true
REDIS_URL=redis://redis:6379
RAILS_MAX_THREADS=5
JUDGE0_API_VERSION=0

You can customize the variables to suit your preferences. For instance, you can change the database URL, set your desired secret key, and decide the number of threads that should be used.

Step 3: Build and Deploy the Application

After setting the environment variables, build the Docker images and deploy the application using the following command:

docker-compose up

Docker Compose will download the required images and start the containers for the API, judge worker, database, and Redis queue.

You can check if the containers are running using the command:

docker ps

The output should be similar to the following:

CONTAINER ID   IMAGE                COMMAND                  CREATED          STATUS          PORTS                      NAMES
58e0b7dc0bdf   judge0/api:nightly   "sh -c 'bin/start'"      18 seconds ago   Up 8 seconds    0.0.0.0:2358->2358/tcp     judge0_api_1
a5c5a5782581   judge0/worker:0.10   "sh -c 'bin/start'"      23 seconds ago   Up 13 seconds                                judge0_worker_1
edbaeb35be6b   redis:5-alpine       "docker-entrypoint.s…"   23 seconds ago   Up 13 seconds   0.0.0.0:6379->6379/tcp     judge0_redis_1
5eb5e55fa1ff   postgres:12.6        "docker-entrypoint.s…"   24 seconds ago   Up 14 seconds   0.0.0.0:5432->5432/tcp     judge0_db_1

This output shows that all containers are running.

Step 4: Testing the Installation

Judge0 CE is ready for execution. However, before you use it, it's recommended to test its functionality. You can run the tests using:

docker exec -it judge0_api_1 bash -c "RAILS_ENV=test bin/rails test"

This command will execute the tests and show the output in the terminal.

Once the tests are complete, you can visit the Judge0 website at http://localhost:2358/ to confirm that it is working correctly.

Conclusion

You have successfully installed Judge0 CE on OpenSUSE Latest. You can now use it to execute and grade code submissions in different languages locally.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!