Unleash Your Code: Introducing executeme
- A Secure & Scalable Code Execution Backend
Ever needed to run arbitrary code securely and efficiently?
Whether youโre building an online judge, a coding playground, an educational platform, or even an automated testing service, executing user-submitted code in a safe and isolated environment is a fundamental challenge. Thatโs where executeme
comes in.
executeme
is a robust and secure backend service designed precisely for this purpose. It allows you to run code snippets in various programming languages within isolated Docker containers, providing both security and scalability.
โจ What is executeme
?
At its core, executeme
is a Node.js-powered API that acts as an intermediary between your application and various language runtimes. When a user submits code, executeme
takes care of spinning up a dedicated, isolated Docker container for that specific execution, runs the code, captures its output (or errors), and then cleans up the environment.
Here are some of its standout features:
-
Multi-Language Support: Out-of-the-box,
executeme
supports Python, Node.js, and Java. Its modular design makes it straightforward to extend support to even more languages based on your needs. -
Secure Docker Isolation: Security is paramount. Every code execution happens within its own ephemeral Docker container. This ensures that user code cannot interfere with other executions or the host system, providing a secure sandbox.
-
Resource Limiting: To prevent malicious code from consuming excessive resources (e.g., infinite loops, memory bombs),
executeme
applies configurable memory and CPU limits to each execution. This safeguards your infrastructure. -
API-Driven: Designed with integration in mind,
executeme
exposes a simple RESTful API endpoint. This makes it easy to hook it into your frontend applications or any other service requiring code execution capabilities. -
Automated Cleanup: No lingering artifacts!
executeme
automatically manages temporary directories and files created for each execution, ensuring a clean and efficient system.
๐ก Why Choose executeme
?
executeme
simplifies a complex problem. Instead of wrestling with container orchestration, security hardening, and managing multiple language runtimes yourself, you can integrate this ready-to-use backend. Itโs perfect for:
-
Online Compilers/Editors: Give your users a place to write and test code live.
-
Coding Challenge Platforms: Automate the execution and evaluation of user solutions.
-
Educational Tools: Provide interactive coding exercises and immediate feedback.
-
DevTools: Quickly test snippets or automate code-dependent workflows.
๐ Getting Started with executeme
Setting up executeme
is designed to be quick and easy thanks to Docker Compose.
Prerequisites
Make sure you have:
-
Docker (Engine & Compose) installed.
-
Node.js (LTS version, e.g., 20.x+) and npm.
Installation & Setup Steps
-
Clone the Repository: Start by cloning the
executeme
GitHub repository to your local machine:git clone https://github.com/devlopersabbir/executeme.git cd executeme
-
Install Node.js Dependencies: Navigate into the
app
directory where the Node.js server is located and install its dependencies:cd app npm install cd ..
-
Build Docker Images: This is a crucial step!
executeme
relies on pre-built Docker images for each language runtime. Build them using Docker Compose:docker compose build
This command will build the following images:
executor-nodejs:latest
executor-python:latest
executor-java:latest
executeme-nodejs-server:latest
(your main backend service)
-
Run the Services: Once all images are built, you can launch the
executeme
backend service using Docker Compose. This will bring up your Node.js server and prepare the environment for code execution.docker compose up
Your Node.js server should now be running and accessible on
http://localhost:3000
.
โ๏ธ How to Use the API
The primary way to interact with executeme
is through its /run
POST endpoint. You send your code and the desired language, and it returns the execution output.
POST /run
Endpoint: http://localhost:3000/run
Method: POST
Content-Type: application/json
Request Body Example:
{
"code": "print('Hello, World!')",
"language": "python"
}
Success Response (Status: 200 OK
):
{
"output": "Hello, World!\n"
}
Error Response (Status: 400 Bad Request
or 500 Internal Server Error
):
{
"error": "Runtime error",
"details": "Traceback (most recent call last):\n File \"main.py\", line 1, in <module>\n print(\"Hello, World\""
}
curl
Examples
Hereโs how you can test it directly from your terminal:
Python Example:
curl -X POST -H "Content-Type: application/json" \
-d '{
"language": "python",
"code": "print(\"Hello from Python!\")\nimport sys\nprint(sys.version)"
}' \
http://localhost:3000/run
Node.js Example:
curl -X POST -H "Content-Type: application/json" \
-d '{
"language": "nodejs",
"code": "console.log(\"Hello from Node.js!\");\nconsole.log(process.version);"
}' \
http://localhost:3000/run
Java Example:
curl -X POST -H "Content-Type: application/json" \
-d '{
"language": "java",
"code": "public class Main { public static void main(String[] args) { System.out.println(\"Hello from Java executor!\"); } }"
}' \
http://localhost:3000/run
๐งโ๐ป Contributing & Supporting
executeme
is a fully open-source project, and contributions are highly encouraged! Whether itโs adding new language support, improving performance, fixing bugs, or enhancing documentation, your input is valuable.
How to Contribute:
- Fork the GitHub repository.
- Clone your fork.
- Create a new branch for your feature or bug fix.
- Make your changes, write tests, and ensure code quality.
- Open a Pull Request with a clear description of your work.
Support the Project:
If executeme
helps you or your project, consider showing your support. Your contributions help maintain and improve this tool for the entire developer community!
- Sponsor on GitHub: https://github.com/sponsors/devlopersabbir
- Buy Me a Coffee: https://buymeacoffee.com/devlopersabbir
๐ Conclusion
executeme
offers a powerful, secure, and flexible solution for executing code in a sandboxed environment. By leveraging Docker, it provides the isolation needed for production use cases while remaining easy to integrate and extend. Give it a try for your next project that requires dynamic code execution!