Docker-based backend javascript compiler
878
Docker-based javascript compiler API server
# download and run kykungz/compilr-javascript image (port 8080)
docker run -it -p 8080:8080 --name compilr-javascript kykungz/compilr-javascript
# clone the repository
git clone https://github.com/kykungz/compilr-javascript.git && cd compilr-javascript
# -----edit config.js file-----
# build an image
docker build -t kykungz/compilr-javascript .
# run kykungz/compilr-javascript image (port 8080)
docker run -it -p 8080:8080 --name compilr-javascript kykungz/compilr-javascript
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-javascript
# OR
# open new tty
docker exec -it compilr-javascript bash
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:
{ "content": <code> }
Example:
{ "content": "let x = 10; console.log('hello world!' + x);" }
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

config.js
| Key | Detail |
|---|---|
| TIMEOUT | Terminal cpu time limit (in seconds) |
| LOG | Logging (boolean) |
Content type
Image
Digest
Size
261.3 MB
Last updated
about 9 years ago
docker pull kykungz/compilr-javascript