Giter VIP home page Giter VIP logo

glot-run's Introduction

glot-run

Build Status

Overview

glot-run provides a http api for running code inside docker containers. The api is described here.

Run

The download above is a standard erlang release that includes a start script. To start glot-run in the foreground type: glot/bin/glot foreground.

Environment variables

glot-run takes it's configuration from environment variables. All vars needs to be set, no default values are provided.

Variable name Allowed values Example Description
API_ENVIRONMENT development | production production Development mode will enable auto compiling of changed files
API_HTTP_LISTEN_IP <ipv4 address> 0.0.0.0 Listen ip
API_HTTP_LISTEN_PORT 1-65535 8090 Listen port
DATA_PATH <filepath> /home/app/data/ Path to save data files (users, languages)
LOG_PATH <filepath> /home/app/log/ Path to save logs
BASE_URL <url> https://run.glot.io Base url to where the api is hosted
ADMIN_TOKEN <string> some-secret Admin token used to access the /admin endpoints
DOCKER_API_URL <url> http://10.0.0.2:2375 Url to docker api (see docker configuration section below)
DOCKER_RUN_TIMEOUT <seconds> 15 Maximum number of seconds a container is allowed to run
MAX_OUTPUT_SIZE <bytes> 100000 Maximum number of bytes allowed from the output of a run

Api users

An api token is required to run code. Users can be created with the /admin/users endpoint. See the api docs for more details.

Languages

Languages can be added with the /admin/languages endpoint. A language has a name, version and the name of a docker image that will be used when running code for the given language/version. See the api docs for more details.

Docker images

When a run request is posted to glot-run it will create a new temporary container from the image that handles the given language/version. The container is required to listen for a json payload on stdin and must write the run result to stdout as a json object containing the properties: stdout, stderr and error. An application that does this is glot-code-runner. Example images can be found here.

Container payload

The payload {"files": [{"name": "main.py", "content": "print(42)"}]} posted to /languages/python/latest will result in this payload being sent to the container: {"language": "python", "files": [{"name": "main.py", "content": "print(42)"}]}. A successful run should yield this response from the container: {"stdout": "42\n", "stderr": "", "error": ""}.

Docker configuration

By default the docker api is only available through a unix socket and it needs to be configured to listen on a tcp socket. On ubuntu this can be done by adding the line DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock" to /etc/default/docker.

glot-run's People

Contributors

prasmussen avatar javierprovecho avatar

Watchers

James Cloos avatar s  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.