• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A remote code running service.

Remote Code Runner

Remote Code Runner is a simple code service for running code on remote server side. Docker is used to execute untrusted code in a sandbox environment.

Install

Environment:

  • Ubuntu Linux 18.04
  • Docker 19.x
  • Python 3.8

MAKE SURE the login user has sudo privileges and does not require entering a password.

Install all required software:

$ sudo apt install git docker.io python3.8

Get source:

$ cd /srv
$ sudo git clone https://github.com/michaelliao/remote-code-runner.git

Generate all from source:

$ cd /srv/remote-code-runner
$ sudo python3.8 generate.py

Download required docker images by warm up script (this may take a long time):

$ cd /srv/remote-code-runner/bin
$ sudo sh warm-up-docker.sh

Start server:

$ cd /srv/remote-code-runner/bin
$ sudo start-runner.sh

Usage

Using simple HTTP JSON API:

$ curl http://server-ip:8080/run -H 'Content-Type: application/json' -d '{"language":"python","code":"import math\nprint(math.pi)"}'
{"error": false, "timeout": false, "truncated": false, "output": "3.141592653589793\n"}

API input:

  • language: language name, lowercase: java, python, ruby.
  • code: language code as JSON string: import math\nprint(math.pi)

API output:

  • timeout: boolean, is execution timeout.
  • error: boolean, is error output. e.g. compile failed or syntax error.
  • truncated: boolean, is output was truncated for too many characters.
  • output: string, the output of execution.

Execution

How code are executed on the remote server side:

  1. Http server runner.py got language name and code from API;
  2. Write code into a temperary directory like /tmp/remote-code-runner/1;
  3. Execute command like sudo docker run -t --rm -w /app -v /tmp/dir:/app <image-tag> python3 main.py;
  4. Write output into API response;
  5. Clean up temperary directory.

Limitation

  • Multiple files are not supported.
  • There is no way to read input from console. Any user input code will cause timeout.

Security

Remote code runner should only be served in private network. User identity check, rate limit must be done in application server or reverse proxy like Nginx.

Extension

How to add a new language:

  1. Add configuration in config.json:
{
    ...
    "languages": {
        ...
        "node": {
            "file": "main.js",
            "image": "node:14.17-slim",
            "command": "node main.js"
        }
    }
}

The key node is the language name.

  1. Make sure image is downloaded on local:
$ sudo docker run -t --rm node:13.12-slim ls
  1. Restart start-runner.sh.

More Repositories

1

learn-python3

Learn Python 3 Sample Code
6,013
star
2

awesome-python3-webapp

ๅฐ็™ฝ็š„Pythonๅ…ฅ้—จๆ•™็จ‹ๅฎžๆˆ˜็ฏ‡๏ผš็ฝ‘็ซ™+iOS Appๆบ็ โ†’ http://t.cn/R2PDyWN ่ตžๅŠฉโ†’ http://t.cn/R5bhVpf
2,299
star
3

awesome-python-webapp

ๅฐ็™ฝ็š„Pythonๅ…ฅ้—จๆ•™็จ‹ๅฎžๆˆ˜็ฏ‡๏ผš็ฝ‘็ซ™+iOS Appๆบ็ 
2,143
star
4

learn-javascript

JavaScriptๅ…จๆ ˆๆ•™็จ‹ๅ‚่€ƒๆบ็ 
1,696
star
5

itranswarp.js

Deprecated. See https://github.com/michaelliao/itranswarp
JavaScript
1,409
star
6

sinaweibopy

ๆ–ฐๆตชๅพฎๅšPython SDK
Python
1,274
star
7

cryptocurrency

Simple Java library to interact with bitcoin
JavaScript
835
star
8

itranswarp

Full-featured CMS including blog, wiki, discussion, etc. Cloud native application that powered by SpringBoot.
Java
713
star
9

shici

ไธญๅŽ่ฏ—่ฏ็ฝ‘็ซ™ www.shi-ci.com ่ฏ—่ฏๆ–‡ไปถๅŠๆบ็ 
JavaScript
466
star
10

learn-python

ๅฐ็™ฝ็š„Pythonๅ…ฅ้—จๆ•™็จ‹๏ผš้ƒจๅˆ†็ซ ่Š‚ๆบ็ 
Python
448
star
11

learngit

ๆ•™็จ‹โ†’ https://www.liaoxuefeng.com/wiki/896043488029600 ๆŽจ้€่ฏทไฝฟ็”จUTF-8็ผ–็ 
406
star
12

compiler

In-memory compile java source code and load compiled classes.
Java
357
star
13

springcloud

JavaScript
221
star
14

warpexchange

A simple, super fast, 7x24 exchange.
Java
182
star
15

githubpy

A simple GitHub REST API SDK for Python3
Python
135
star
16

jsonstream

A fast streaming parser for JSON. Learn how to design:
Java
114
star
17

openweixin

ๅฏ่ƒฝๆ˜ฏๆœ€ๅฅฝ็”จ็š„ๅพฎไฟกๅ…ฌไผ—ๅทJavaๅผ€ๅ‘ๅŒ…
CSS
107
star
18

learn-sql

Java
100
star
19

summer-framework

Summer framework is a minimal Spring framework.
Java
84
star
20

miniweibo

ไฝฟ็”จPythonๅผ€ๅ‘็š„ๅŸบไบŽๆ–ฐๆตชๅพฎๅšAPI็š„่ฟทไฝ ๅพฎๅš็ฝ‘็ซ™
Python
81
star
21

warpdb

DSL-driven RDBMS interface for Java.
Java
79
star
22

simple-match-engine

A simple, fast match engine for trading
Java
44
star
23

transwarp

A simple Python framework for web, db and mail.
Python
42
star
24

learn-verilog

Learn Verilog
Verilog
29
star
25

red-packet-contract

Crypto red packet with zk-proof.
HTML
28
star
26

simple-trading-engine

Java
27
star
27

how-to-become-rich

A sample Maven repo that makes you rich.
Java
26
star
28

algorithms

Java
18
star
29

tts

A simple TextToSpeech desktop application based on Microsoft Speech SDK.
Java
15
star
30

cljweb

A clojure web project for start
Clojure
13
star
31

virtual-keyboard

Virtual keyboard is a simulated keyboard with RS-232 serial port support.
C#
12
star
32

mysql-warp

Fast, simple ORM for mysql on Node.js
JavaScript
12
star
33

vote-dapp

Simple dapp for Ethereum
HTML
12
star
34

irunning

iRunning scans your weibo and creates your running report automatically.
Python
11
star
35

periodic-table

Periodic Table / ๅ…ƒ็ด ๅ‘จๆœŸ่กจ
HTML
11
star
36

mnist

A mnist demo app.
Python
11
star
37

rtmp-livestreaming

Forked from http://code.google.com/p/rtmplite/
Python
11
star
38

crypto-tele-bot

A telegram bot to track crypto market
Java
9
star
39

simple-nft

A simple EIP-1155 based NFT tool.
HTML
9
star
40

blockchain-lib

Generate client-side library for blockchain
JavaScript
9
star
41

learn-english-word

HTML
8
star
42

chatbot

Chat bot driven by AI.
HTML
8
star
43

jxrest

Simple, lightweight Java REST framework
Java
8
star
44

contract-deployer

A contract deployer that support deploy contract with user-defined prefix. e.g. 0xCafe
HTML
8
star
45

es-wrapper

Wrapper for Elastic Search
Java
7
star
46

git-explorer

File explorer for a subdir of repo which can embedded to web page.
JavaScript
7
star
47

jhtml5player

HTML 5 Player on jQuery
JavaScript
7
star
48

eth-smt

Sparse Merkle Tree for Ethereum
Java
7
star
49

oauth2-warp

A simple, fast OAuth2 library for Nodejs.
JavaScript
7
star
50

learn-docker

Python
7
star
51

llm-embedding-sample

LLM Embedding Sample App using Flask and PostgreSQL with pgvector extension.
HTML
6
star
52

nft-generator

Generate NFTs
6
star
53

www-start-script

A simple script to start a www server for static resources.
HTML
5
star
54

1024pixels

Create 32 x 32 = 1024 pixels art as NFT on Polygon blockchain.
HTML
5
star
55

michaelliao.github.com

Michael Liao @ GitHub
CSS
4
star
56

jexieditor

Automatically exported from code.google.com/p/jexieditor
Java
4
star
57

web3stack

A demo for Web3 stack.
HTML
4
star
58

simple-assets

Java
4
star
59

jerrymouse

Jerrymouse is a mini version of Tomcat.
Java
4
star
60

awesome-nodejs-webapp

4
star
61

weather-china

Automatically exported from code.google.com/p/weather-china
Python
4
star
62

githubpy-test

Test repo for githubpy, updated at 2023-01-22 18:15
3
star
63

download

Free downloads
3
star
64

complex

A sample maven project for deploy test
Java
3
star
65

gitskills

3
star
66

warpchain

Java
3
star
67

gitdocs

Generate Docs by Git Repo
HTML
3
star
68

kof-chrome-theme

The King of Fighters Theme for Chrome.
3
star
69

michaelliao

Github profile page
HTML
3
star
70

serial-send-image

C#
2
star
71

netlify-static

Deploy static website to netlify.
JavaScript
2
star
72

ssi-server

Server-Side-Includes Server & Generate Static Pages.
HTML
2
star
73

livebookstore

Automatically exported from code.google.com/p/livebookstore
Java
2
star
74

stablecoin-simulator

Algorithmic stable coin simulator
2
star
75

netlify-avatar

Generate GitHub-like avatar by netlify functions.
JavaScript
2
star
76

airdrop-contract

Airdrop contract that support millions of airdrops on ETH-compatible chain.
2
star
77

maven-packages

2
star
78

webwind

(Deprecated) Automatically exported from code.google.com/p/webwind
HTML
2
star
79

compostable-nft

A compostable, lower gas cost NFT solution.
2
star
80

jsonstream-doc

jsonstream documentation
Python
2
star
81

wechatbot

Bot for WeChat
1
star
82

image-processor

In-browser image processor, no server-side logic.
HTML
1
star
83

jxrest-doc

jxrest documentation
Python
1
star
84

locking-vault-contract

Lock tokens with linear release.
HTML
1
star
85

shorten-url

Simple URL shortener that build without magic.
1
star