Self-Hosting Judge0 API on Windows: A Step-by-Step Guide

What is Judge0?

Judge0 is an open-source project that allows you to execute code online using the Judge0 API. You can set test cases for the code, so when Judge0 executes it, those test cases will be tested as well. In case of any compiler error or test case pass/fail, you will receive all the information in the API result. It supports multiple languages as well.

What are the use cases?

You can use Judge0 to create your own code execution platforms like JDoodle, Programiz, LeetCode, GFG, etc., where users can write and run their code and set cases, or you can set coding problems where users just write the solution, and you can test them.

Let’s start the step up for Judge0

First, we will install Docker on our system. Once that's done, we will use Docker to create an image of Judge0, which will run on Docker.

Let’s first install docker

  1. Please open the URL below. and download the docker for windows.

    Windows | Docker Docs (https://docs.docker.com/desktop/setup/install/windows-install/)

Note -: To run the docker there are 2 ways to run the docker in windows one is Hyper-V and WSL. here we are going to use WSL as I am using windows home.

For WSL

  • Windows 11 64-bit: Home or Pro version 22H2 or higher, or Enterprise or Education version 22H2 or higher.

  • Windows 10 64-bit: Minimum required is Home or Pro 22H2 (build 19045) or higher, or Enterprise or Education 22H2 (build 19045) or higher.

For Hyper-V

  • Windows 11 64-bit: Enterprise, Pro, or Education version 22H2 or higher.

  • Windows 10 64-bit: Enterprise, Pro, or Education version 22H2 (build 19045) or higher.

Why we need WSL or Hyper-V to work docker in windows?

WSL (Windows Subsystem for linux) is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows 11. It allows developers to use a Linux environment without the overhead of a virtual machine.

  1. Please select WSL2 while installing docker for windows home.

  2. Please wait till installation completed once done please restart your system.

then open the docker if you are seeing screen like below its mean installation completed or you can run this docker --version on your cmd to check if its installed or not .

Let’s setup the judge0

  1. Let’s download the Judge0 zip file in your local using below URL

    https://github.com/judge0/judge0/releases/download/v1.13.1/judge0-v1.13.1.zip

  2. Once file downloaded Unzip the file then open judge0.conf file.

  3. Search these two field REDIS_PASSWORD, POSTGRES_PASSWORD and then set the password for these two fields

  4. Now open your CMD with your judge0 file path location. for that just click on path location remove everything right cmd and hit enter it will automatically open CMD with same file location

    OR you can copy the path then open the CMD and give cd filepath and hit enter. you can use any of them.

    OR

  5. Now run this command docker-compose up -d Once you run this system will start pulling all the images those are mentioned in docker-compose file under services.

    Note -: Please make sure docker is running in background

    Please wait a few minutes; it will depend on your internet and system. Once done, you will see something like the below in your CMD.

  6. If you want to see the currently running services on your docker, you can run this command:

    docker-compose ps or you can check in your Docker application. Please refer to the images below.

    OR

  7. Now, if everything is up and running fine, please visit http://localhost:2358/docs, and if you see the result below, it means the Judge0 setup is completed successfully.

Thank you very much for reading this. I hope this helped you to set up Judge0 on your local system. Please leave a comment and hit the like button. Let me know if I missed anything or if you think anything can be improved.

0
Subscribe to my newsletter

Read articles from Shivendra sonkar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shivendra sonkar
Shivendra sonkar