Server-side code of a Remote Code Executor
Report Bug
·
Request Feature
This is the server-side code of a Remote Code Executor. This is a project assigned by the Coding forum of my college and is similar to the Online IDEs of websites like CodeChef and Leetcode.
Salient Features:
- Code Sanitisation
- An individual Docker Container is created for every code posted on the API, so no code interferes with any other code
- All Async code so that the server can handle multiple requests without error
- Socket has been implemented along with rooms for seperate users so that the server can handle multiple users in multiple rooms
- Keeping it simple, there is not need for signup or login, you can jump in and start coding
- Timeouts and max memory have been implemented so that no code takes up too much of the server's time
- Implemented SwaggerUI as an API Sandbox so anyone can explore endpoints and familiarize themselves with the server.
To get a local copy up and running follow these simple steps.
- npm
npm install npm@latest -g
- docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
- Clone the repo
git clone https://github.com/rajatmaheshwari2512/remote-code-exec
- Install NPM packages
npm install
- To build the docker images
cd Dockerfiles
docker build -t cpp:v1 -f DockerCPP .
docker build -t python:v1 -f DockerPython .
docker build -t java:v1 -f DockerJava .
docker build -t go:v1 -f DockerGo .
docker build -t c:v1 -f DockerC .
- Clone the repo
git clone https://github.com/rajatmaheshwari2512/remote-code-exec
- Install NPM packages
npm install
- Build the Server's Dockerfile
docker build -t rceserver:v1 .
- Run the Docker Image
docker run --privileged=true -v /var/run/docker.sock:/var/run/docker.sock -d -p 3000:3000 rceserver:v1
- Create a shell to the created Docker Container
docker ps
docker exec -it <container_id> /bin/bash
- Build the Images inside the Container
cd Dockerfiles
docker build -t cpp:v1 -f DockerCPP .
docker build -t python:v1 -f DockerPython .
docker build -t java:v1 -f DockerJava .
docker build -t go:v1 -f DockerGo .
docker build -t c:v1 -f DockerC .
- To run the server in dev mode use
npm run dev
- To run the server in production mode
npm start
- Note that dev mode uses nodemon so that the server can be changed and restarted easily
- It is important to note that you will have to setup environment variables to the appropriate endpoints, should you deploy this locally or somewhere else
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Rajat Maheshwari - [email protected]
Project Link: https://github.com/rajatmaheshwari2512/remote-code-exec
Site Link: SwaggerUI Link
Main Site Link: FrontEnd UI
- This project is currently deployed on an EC2 Instance provided by AWS