Deploy JudgeLib on your own infrastructure with Docker and Kubernetes for maximum control, reliability, and performance.
Select how you want to get started with JudgeLib self-hosting
Workflow overview and architecture
Detailed step-by-step written guide
Ready-to-use code examples and snippets
Understand the self-hosting architecture and deployment process.

Install lib-judge in your application
Run the worker container with Redis
Auto-scale with Kubernetes
Chocolatey is a package manager for Windows that simplifies the installation of software and dependencies. It is required for managing packages in your self-hosted environment.
Note: Follow the official Chocolatey installation guide to ensure proper setup. You may need administrator privileges to install Chocolatey on your system.
The Kubernetes CLI (kubectl) is required to interact with your Kubernetes cluster. You can install it using Chocolatey after the package manager is set up.
Tip: After installation, verify by running kubectl version --client in your terminal.
Kind is a tool for running local Kubernetes clusters using Docker containers as nodes. It's especially useful for testing and development environments.
Tip: After installation, verify Kind is installed by running kind version in your terminal.
Helm is a package manager for Kubernetes that helps you define, install, and upgrade Kubernetes applications. Use it to deploy monitoring and other services to your cluster.
Tip: Helm makes it easy to manage complex Kubernetes deployments with pre-configured charts.
Port forwarding allows you to access Redis running inside your Kubernetes cluster from your local machine. This is useful for development and debugging purposes.
Tip: This command forwards port 6379 from your Redis pod to your local machine.
First, install the lib-judge package in your Node.js application:
npm install lib-judgeCreate a .env file and add the Redis configuration variables:
Pull the worker image and run it with your Redis configuration:
docker pull lightningsagar/worker:210b8cfd943b24e7381c4c8f1f3114c2d1fd3d81Clone the operations repository that contains Kubernetes configurations with horizontal pod autoscaling:
git clone https://github.com/lightning-sagar/worker-opsCustomizable: You can modify the code in the ops repository to suit your specific deployment requirements and infrastructure needs.
Deploy your JudgeLib worker with horizontal pod autoscaling enabled
Create Cluster:
kind create cluster --config .\cluster.yml -n workers-clustersCreate namespace:
kubectl create namespace judge-namespaceApply the deployment configuration:
kubectl apply -f judge-workersThe HPA configuration automatically scales your worker pods based on CPU usage and request load, ensuring optimal performance and cost efficiency.
Here's how to use the lib-judge package in your Node.js application
const result = await judge({
codePath: tmpPath,
ques_name: `question_${Date.now()}`,
input,
output,
timeout: timeout, // in seconds
sizeout: sizeout,
language: langCode, // py, cpp, java
});// or checkout the full code example here https://github.com/lightning-sagar/Judge/
codePathPath to the code file to execute
ques_nameUnique identifier for the question/execution
inputInput data for the code execution
outputExpected output for validation
timeoutExecution timeout in seconds
sizeoutMemory limit for execution
languageProgramming language (py, cpp, java)