Sign inSign up

kykungz/compilr-java

By kykungz

•Updated about 9 years ago

Docker-based java compiler API server

Image
0

908

kykungz/compilr-java repository overview

⁠compilr-java

Docker-based java compiler API server

⁠Installation

⁠1.) Download directly from Docker Hub
# download and run kykungz/compilr-java image (port 8080)
docker run -it -p 8080:8080 --name compilr-java kykungz/compilr-java
⁠2.) Clone and build new image (Configurable)
# clone the repository
git clone https://github.com/kykungz/compilr-java.git && cd compilr-java

# -----edit config.js file-----

# build an image
docker build -t kykungz/compilr-java .
# run kykungz/compilr-java image (port 8080)
docker run -it -p 8080:8080 --name compilr-java kykungz/compilr-java

With this installation, you can configure the environment by editing config.js file before building an image. See Configuration⁠ below.


After running the script above, you can now access your container using command:

# open current tty
docker attach compilr-java

# OR

# open new tty
docker exec -it compilr-java bash

⁠Usage

⁠Request

Compilr will create a simple API server on port 8080 by default. You can compile and run your code by sending a HTTP POST request to your https://localhost:8080/compile⁠ route, with a JSON request body similar to:

{ "files": [
  {
    "name": <class_name>,
    "content": <source_code>
  },
  {
    "name": <class_name>,
    "content": <source_code>
  }
] }

Example:

{ "files": [
 {
     "name": "Run",
     "content": "public class Run {public static void main(String[] arg) {System.out.println(Hello World!);}}"
 }
] }
⁠Response

The response will be in JSON format with structure:

{
    "success": <boolean>,
    "output": <runnig_result>
}

Example:

{
    "success": true,
    "output": "hello world!10\n"
}

If there is a compile/run error, success field will be false and the error output will be shown.


compilr also provide a simple code editor frontend on your https://localhost:8080⁠

frontend image

⁠Configuration

config.js

KeyDetail
TIMEOUTTerminal cpu time limit (in seconds)
LOGLogging (boolean)

Tag summary

Content type

Image

Digest

Size

329.9 MB

Last updated

about 9 years ago

docker pull kykungz/compilr-java