Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerised using Docker and integrated with client #13

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
16 changes: 16 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
],
"plugins": [
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining"
]
}
3 changes: 3 additions & 0 deletions .cfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
/server
/public
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
public/api-explorer/
*.yaml
*.yml
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parser": "babel-eslint",
"extends": ["eslint:recommended", "plugin:node/recommended", "prettier"],
"env": {
"mocha": true
},
"plugins": ["prettier", "node"],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": 2,
"node/no-unsupported-features/es-syntax": 0,
"node/no-unpublished-import": ["off"],
"prettier/prettier": [
"error",
{
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"printWidth": 80
}
]
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
dist
.env
.DS_Store
sample.cpp
sample.py
sample.js
run
run.exe
7 changes: 7 additions & 0 deletions .nodemonrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"watch": [
"server/**/*.*",
".env"
],
"ext": "js,json,mjs,yaml,yml"
}
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu
RUN apt-get update -y
RUN apt-get install curl -y
RUN curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install nodejs -y
RUN apt-get update -y
RUN apt install docker.io -y
# WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm","run","dev"]
# docker run -it -d --name my_server -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --mount source=my_vol,target=/executor server:2.0
55 changes: 51 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,61 @@
# Remote-Code-Executor

RCE is a Remote Code Executor, as the name suggests Is a Docker-based sandbox environment to run a code snippet. It will create a new docker based container for every submitted code, run it in the isolated container, and return the output. It will support major languages C, C++, and can be extended to other language support too.

# Features:
- Backend APIs and logic to handle the submitted code, create a docker container, execute it, and return the results.

- Backend APIs and logic to handle the submitted code, create a docker container, execute it, and return the results.
- Minimal UI for user interaction and code submission.
- Can be extended to an Online Code Judge and full-fledged coding/interview platform.

# Tech stack:
# Tech stack:

- Node.js
- Any Frontend framework or Basic HTML
- Any Frontend framework or Basic HTML
- Javascript
- Docker
- Docker
- Bash scripting.

## Get Started

### Get started developing...

```shell
# build docker image
docker-compose build

# create volume
docker volume create my_vol

# run server in development mode
docker-compose up server
```

`
This will build the required docker image and run the server in a docker container which will be listening at http://localhost:3000.

### For development and adding features

Install all package dependencies (one time operation)

```shell
npm install
```

Runs the application is development mode. Should not be used in production

```shell
npm run dev
```

This is for
development of the application.

#### Run in _production_ mode:

Compiles the application and starts it in production production mode.

```shell
npm run compile
npm start
```
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
server:
image: server:1.0
build: .
ports:
- '3000:3000'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- my_vol:/executor
executor:
image: executor:1.0
build: ./executor
volumes:
- my_vol:/app/codes
volumes:
my_vol:
external: true
16 changes: 16 additions & 0 deletions executor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu

RUN apt-get update -y
RUN apt install nodejs -y
RUN apt-get -y upgrade
RUN apt-get install python -y
RUN apt-get update -y
RUN apt-get install gcc -y
RUN apt-get update -y
RUN apt-get install g++ -y
RUN apt-get update -y
RUN apt install default-jdk -y
RUN apt install openjdk-11-jdk-headless -y
RUN apt install ecj -y
RUN apt install openjdk-8-jdk-headless -y
RUN mkdir app
Loading