Skip to content

singhularity/dockercodecompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

The "Docker Code Compiler" can be used to run adhoc code in a "sandboxed" mode. Basically, it brings up a temporary docker instance, runs your code and then returns any output/error generated after running the code. The library can run as a service or for a "single" run

Uses

You can use it to run any code in a sandbox so you don't risk untrusted sources messing up your server contents. A good example is an online code compiler application!

Set Up

  • Install go
  • Checkout code in $GOPATH/src/github.com

Run Docker setup

  • cd docker_setup
  • ./BuildCompilerDockerImage.sh

Build Library

  • go build start.go

If you see errors like "undefined: client.NewClientWithOpts", run the following

  • go get github.com/docker/docker@master

Usage

Can be run in "service" OR "Local" mode

To run as service

`./start svc`

You can then Post requests to http://localhost:8090/api/compile

  • Java Example

    curl -X POST \ http://localhost:8090/api/compile \ -d '{ "language": "java", "code": "class HelloWorld { public static void main(String[] args) { System.out.println(\"Hello \" + args[0]);}}", "stdin": "World!" }'

  • Python Example

    curl -X POST \ http://localhost:8090/api/compile \ -d '{ "language": "python", "code": "print('\''Hello World!'\'')" }'

To run single instance

  • Java Example
    ./start local java "class HelloWorld { public static void main(String[] args) { System.out.println(\"Hello \" + args[0]);}}" world!
  • Python Example
    ./start local python "print('Hello')"

Supported Languages


Java
Python3
Python
PHP
Ruby
Scala
GoLang

About

A docker based pluggable compiler built with Go!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published