A secure, containerized code execution service that allows running code in multiple programming languages through a REST API. The engine uses Docker containers to provide isolated execution environments for Python, Node.js, and Go.
- Multi-language Support: Execute code in Python, Node.js, and Go
- Isolated Execution: Each code execution runs in its own Docker container
- Timeout Control: Configurable execution timeouts (max 20 seconds)
- Input Support: Accept stdin input for interactive programs
- REST API: Simple HTTP interface for code execution
- Container Pooling: Pre-warmed containers for faster execution
- Python 3.11 (Alpine Linux)
- Node.js (Alpine Linux)
- Go (Alpine Linux)
Endpoint: POST /execute
Request Body:
{
"language": "python|node|go",
"code": "print('Hello World')",
"stdin": "optional input",
"timeout": 10
}Parameters:
language(required): The programming language ("python", "node", or "go")code(required): The source code to executestdin(optional): Input to pass to the program via stdintimeout(optional): Execution timeout in seconds (1-20, default: 20)
Response:
{
"stdout": "Hello World\n",
"stderr": "",
"exitCode": 0,
"duration": 0.123
}Endpoint: GET /
Returns: "CEE Running"
- Go 1.24+
- Docker
- Make (optional, for convenience commands)
git clone <repository-url>
cd ceev2
go mod downloadBuild all language runtime images:
make build-allOr build individually:
make build-python
make build-node
make build-gogo run main.goThe server will start on port 3000.
curl -X POST http://localhost:3000/execute \
-H "Content-Type: application/json" \
-d '{
"language": "python",
"code": "name = input()\nprint(f\"Hello, {name}!\")",
"stdin": "World"
}'curl -X POST http://localhost:3000/execute \
-H "Content-Type: application/json" \
-d '{
"language": "node",
"code": "console.log(\"Hello from Node.js!\");"
}'curl -X POST http://localhost:3000/execute \
-H "Content-Type: application/json" \
-d '{
"language": "go",
"code": "package main\nimport \"fmt\"\nfunc main() { fmt.Println(\"Hello from Go!\") }"
}'The system consists of several components:
- API Server: HTTP server built with Fiber framework
- Executor: Manages code execution requests
- Docker Client: Interfaces with Docker API
- Pool Manager: Maintains a pool of pre-warmed containers
- Sandbox: Provides isolated execution environment
- Language Loader: Loads language configurations from JSON
- Code execution is isolated in Docker containers
- Non-root user execution in containers
- Automatic cleanup of temporary files
- Configurable execution timeouts
- Input validation and sanitization
make tester├── main.go # Application entry point
├── go.mod # Go module definition
├── Makefile # Build automation
├── docker/ # Docker configurations
│ ├── python/
│ ├── node/
│ └── go/
├── internal/
│ ├── api/ # HTTP API handlers
│ ├── docker/ # Docker client and pooling
│ ├── Executer/ # Code execution logic
│ ├── languages/ # Language configuration
│ ├── sandbox/ # Execution sandbox
│ └── utils/ # Utility functions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request