{"id":20580151,"url":"https://github.com/michaelliao/remote-code-runner","last_synced_at":"2025-05-09T21:34:33.999Z","repository":{"id":140002604,"uuid":"253175010","full_name":"michaelliao/remote-code-runner","owner":"michaelliao","description":"A remote code running service.","archived":true,"fork":false,"pushed_at":"2021-05-19T11:56:02.000Z","size":20,"stargazers_count":134,"open_issues_count":0,"forks_count":29,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-21T20:18:17.464Z","etag":null,"topics":["docker","remote-code-execution"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelliao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-05T07:00:32.000Z","updated_at":"2025-02-27T07:39:44.000Z","dependencies_parsed_at":"2023-05-01T03:47:42.551Z","dependency_job_id":null,"html_url":"https://github.com/michaelliao/remote-code-runner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelliao%2Fremote-code-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelliao%2Fremote-code-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelliao%2Fremote-code-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelliao%2Fremote-code-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelliao","download_url":"https://codeload.github.com/michaelliao/remote-code-runner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253328836,"owners_count":21891534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","remote-code-execution"],"created_at":"2024-11-16T06:20:55.101Z","updated_at":"2025-05-09T21:34:33.962Z","avatar_url":"https://github.com/michaelliao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Remote Code Runner\n\nRemote 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.\n\n# Install\n\nEnvironment:\n\n- Ubuntu Linux 18.04\n- Docker 19.x\n- Python 3.8\n\nMAKE SURE the login user has `sudo` privileges and does not require entering a password.\n\nInstall all required software:\n\n```\n$ sudo apt install git docker.io python3.8\n```\n\nGet source:\n\n```\n$ cd /srv\n$ sudo git clone https://github.com/michaelliao/remote-code-runner.git\n```\n\nGenerate all from source:\n\n```\n$ cd /srv/remote-code-runner\n$ sudo python3.8 generate.py\n```\n\nDownload required docker images by warm up script (this may take a long time):\n\n```\n$ cd /srv/remote-code-runner/bin\n$ sudo sh warm-up-docker.sh\n```\n\nStart server:\n\n```\n$ cd /srv/remote-code-runner/bin\n$ sudo start-runner.sh\n```\n\n# Usage\n\nUsing simple HTTP JSON API:\n\n```\n$ curl http://server-ip:8080/run -H 'Content-Type: application/json' -d '{\"language\":\"python\",\"code\":\"import math\\nprint(math.pi)\"}'\n{\"error\": false, \"timeout\": false, \"truncated\": false, \"output\": \"3.141592653589793\\n\"}\n```\n\nAPI input:\n\n- language: language name, lowercase: `java`, `python`, `ruby`.\n- code: language code as JSON string: `import math\\nprint(math.pi)`\n\nAPI output:\n\n- timeout: boolean, is execution timeout.\n- error: boolean, is error output. e.g. compile failed or syntax error.\n- truncated: boolean, is output was truncated for too many characters.\n- output: string, the output of execution.\n\n# Execution\n\nHow code are executed on the remote server side:\n\n1. Http server `runner.py` got language name and code from API;\n2. Write code into a temperary directory like `/tmp/remote-code-runner/1`;\n3. Execute command like `sudo docker run -t --rm -w /app -v /tmp/dir:/app \u003cimage-tag\u003e python3 main.py`;\n4. Write output into API response;\n5. Clean up temperary directory.\n\n# Limitation\n\n- Multiple files are not supported.\n- There is no way to read input from console. Any user input code will cause timeout.\n\n# Security\n\nRemote 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.\n\n# Extension\n\nHow to add a new language:\n\n1. Add configuration in `config.json`:\n\n```\n{\n    ...\n    \"languages\": {\n        ...\n        \"node\": {\n            \"file\": \"main.js\",\n            \"image\": \"node:14.17-slim\",\n            \"command\": \"node main.js\"\n        }\n    }\n}\n```\n\nThe key `node` is the language name.\n\n2. Make sure image is downloaded on local:\n\n```\n$ sudo docker run -t --rm node:13.12-slim ls\n```\n\n3. Restart `start-runner.sh`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelliao%2Fremote-code-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelliao%2Fremote-code-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelliao%2Fremote-code-runner/lists"}