Open-source online code execution system featuring a playground and sandbox. Built on Docker images with robust isolation provided by Google gVisor.
The system is easily extensible with additional technologies and languages.
Inspired by:
- Judje0 Playground: https://github.com/judge0/judge0
- Google Playground: https://github.com/golang/playground
![Screenshot 2025-02-04 at 01 04 36](https://private-user-images.githubusercontent.com/11223987/409287328-dc79a2c8-b095-4987-909e-239f0d0afc74.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODMyMTYsIm5iZiI6MTczOTI4MjkxNiwicGF0aCI6Ii8xMTIyMzk4Ny80MDkyODczMjgtZGM3OWEyYzgtYjA5NS00OTg3LTkwOWUtMjM5ZjBkMGFmYzc0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE0MDgzNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUyNDNkMzAwZDZiN2NjZWVhYTlmYWIwMDA5NjdhOTk3MDI4ZjQ4N2U4ZGYzOWJiMmIwZmJhNmIyODc1ZjJhMWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.mWPG2c95akDiBCyc4Zfe25MOhMEVfd9LPyTCy3vXjvc)
Playground demonstration in the codiew.io service — soon will be available for you.
- Multi-Language Support: Run Python, Go, PHP and Node.js or your built code with others configurations and versions what you can think, in isolated Docker containers.
- Multi-Files Support: Run code that consists of multiple files
- Easy extensible: You can create your own build to run code via API or by loading a folder with configurations at startup.
- (in working) Dependency Management: Automatic handling of project dependencies (pip, go mod, npm)
- Flexible Execution: Custom entrypoints for both single-file code and full projects
- Scalable System: Expandable via a load balancer between a playground and a sandbox.
Why need isolation
// TODO::
[!] The ability to register Docker images via API is not yet implemented and will be available in the near future!
Out of the box (in development), Dockerfiles and configurations for various languages can be found in /sandbox/dockerfiles
# Input request result:
POST https://codenire.io/run
Content-Type: application/json
{
"templateId": "golang_1_23",
"files": {
"main.go": "package main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n)\n\nfunc main() {\n\t// Process command-line arguments\n\tname := flag.String(\"name\", \"default\", \"User name\")\n\tflag.Parse()\n\n\t// Read data from stdin\n\tvar input string\n\t_, err := fmt.Scan(&input)\n\tif err != nil {\n\t\tfmt.Println(\"Error reading from stdin:\", err)\n\t\treturn\n\t}\n\n\t// Print arguments and stdin data\n\tfmt.Printf(\"Hello, %s!\\n\", *name)\n\tfmt.Printf(\"Stdin data: %s\\n\", input)\n}\n"
},
"args": "--name \"Mark\"",
"stdin": "100.00"
}
# Output result:
{
"Events": [
{
"Kind": "stdout",
"Message": "Hello, Mark!\nStdin data: 100.00\n"
}
]
}
Full API spec available here: https://codiewio.github.io/codenire/api/
You can Run Playground local (or on MacOS/Ubuntu) via Docker Compose.
[!] If you start on MacOS you can't start with gVisor Environment
services:
playground:
container_name: play_dev
build:
context: .
dockerfile: Dockerfile
ports:
- "8081:8081"
volumes:
# You can set up your path with go-plugin
- ./var/plugin/plugin:/plugin
# You can set up your path with plugin scripts (see docs/docker-compose dir with examples)
- ./var/plugin/hooks-dir:hooks-dir
restart: always
networks:
- "sandnet"
entrypoint: [
"/playground",
"--backend-url", "http://sandbox_dev/run",
"--port", "8081",
"--hooks-plugins", "/plugin",
# "--hooks-dir", "/hooks-dir",
]
sandbox:
container_name: sandbox_dev
build:
context: ./sandbox
dockerfile: Dockerfile
ports:
- "8082:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# You can set up your path with configs
- ./var/dockerfiles:/dockerfiles
networks:
- sandnet
restart: always
entrypoint: [
"/usr/local/bin/sandbox",
"--dockerFilesPath", "/dockerfiles",
"--replicaContainerCnt", "1",
"--port", "80",
]
networks:
sandnet:
name: codenire
- Docker compose (see /docs/docker-compose dir — without external gVisor Runtime)
- Digital Ocean Terraform with load balancing and multi-sandbox cluster
TODO:: add description
- Add MultiFiles/singe scripts
- Add gVisor Isolation
- Add Hooks to catch/override some request (for auth, for handle code in external system)
- Add Multi actions in once container (different runs in one docker img, for example multi version of c++ in cpp container)
- Add WebUI Head with Monaco
- Add Metrics
- Add Tests
- Add GoLinter
- Playground
- Sandbox
- Add debug info in API req/resp
- Change container replica strategy
- Add StateFull sandbox
- Compile with open network
- Add WS messaging
- Add action create route
- Add out provider of templates (S3...)