Arbitrary code execution server using Docker https://github.com/SunRed/myriad
Go to file
Manuel 1205933acd
Update images and reduce their size (#13)
* Allow container to be run with custom command

* Reduce language image sizes

* Update OpenJDK to latest version

* Use swc for TypeScript and don't print by default

* Update Haskell image and use stable Debian slim

* Fix formatting and revert TS changes
2021-05-31 00:20:21 -04:00
.github/workflows github: update build.yaml 2020-06-22 06:08:12 -04:00
app switch from dhall to yaml 2020-06-16 22:02:12 -04:00
languages Update images and reduce their size (#13) 2021-05-31 00:20:21 -04:00
src Check if image exists before building (#12) 2021-05-20 23:53:13 -04:00
.gitignore switch from dhall to yaml 2020-06-16 22:02:12 -04:00
Dockerfile Update images and reduce their size (#13) 2021-05-31 00:20:21 -04:00
Dockerfile.release Update images and reduce their size (#13) 2021-05-31 00:20:21 -04:00
LICENSE deps: use Stack LTS 15.15 and update deps 2020-06-07 01:47:33 -04:00
README.md add output size to readme 2020-06-22 02:56:19 -04:00
Setup.hs Initial commit 2019-07-09 05:19:41 -04:00
cabal.project meta: remove hpack and local files 2020-06-16 21:10:23 -04:00
config.example.yaml Add setting for custom runtime of containers (#10) 2021-05-08 13:21:29 -04:00
docker-compose.example.yaml Add Dockerfile and docker-compose example (#11) 2021-05-08 13:22:12 -04:00
hie.yaml.cbl meta: add hie.yaml files for others to use 2020-06-19 09:37:41 -04:00
hie.yaml.stack meta: add hie.yaml files for others to use 2020-06-19 09:37:41 -04:00
myriad.cabal meta: bump version to 0.5.0.3 2020-06-22 06:11:12 -04:00
stack.yaml update stack.yaml 2020-06-22 03:38:12 -04:00

README.md

Myriad

Arbitrary code execution server using Docker.
Each language has its own Docker image and so each evaluation will run in the respective language's locked-down container.

Features include:

  • Building images on startup.
  • Preparing containers on startup or on demand.
  • Periodically cleanup running containers.
  • Customizable settings for each image:
    • Maximum memory usage.
    • Maximum CPU usage.
    • Maximum evaluation time.
    • Maximum concurrent evaluations.
    • Maximum number of retries.
    • Maximum output size.

Requires Docker 18+ to operate.

Download Pre-Built Binary

Check the Releases tab for pre-built binaries.
The languages folder and an example configuration are also included.

Installation from Source

You can use either stack or cabal.

  • stack should be >= 2.1.1, cabal should be >= 2.4.0.0.
  • GHC 8.8.3 is required if not already installed by stack or if using cabal.

Make sure the place where stack or cabal places binaries is in your PATH.

  • For stack, you can get it with stack path --local-bin.
  • For cabal, you should find it in $HOME/.cabal/bin (Linux) or %APPDATA%\cabal\bin (Windows).

Run stack install or cabal new-install inside the project folder.
Or, to build within the project, run stack build or cabal new-build.

Configure and Run

Make sure the configuration is filled out, see config.example.yaml for an example.
Run myriad (or stack run or cabal new-run if you built within the project) to start the server.
The config and languages folder will default to ./config.yaml and ./languages.
You can configure this with --config and --languages.

Endpoints

GET /languages

List of enabled languages.
Example response:

["haskell", "javascript"]

POST /eval

Evaluate code.
JSON payload with language and code keys.
The language is as in the name of a subfolder in the languages directory.
Example payload:

{ "language": "haskell", "code": "main = print (1 + 1)" }

Example response:

{ "result": "2\n" }

Errors with 404 if language is not found, 504 if evaluation timed out, or 500 if evaluation failed for other reasons.

GET /containers

List of containers being handled by Myriad.

POST /cleanup

Kill all containers, giving back the names of the containers killed.