Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hrkt committed Jul 28, 2019
0 parents commit cd4c129
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
@@ -0,0 +1,13 @@
# BUILD
FROM hrkt/command-as-a-service:latest as build-stage

# Production
FROM ubuntu:19.10 as production-stage
RUN apt-get update && apt-get install -y \
musl-dev \
pandoc
COPY --from=build-stage /command-as-a-service .
COPY app-settings.json .
EXPOSE 8080
CMD ["./command-as-a-service"]

21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Hiroki Ito

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
17 changes: 17 additions & 0 deletions Makefile
@@ -0,0 +1,17 @@
NAME :=pandoc-as-a-service
LABEL :=pandoc-as-a-service:0.1.0

# container

build-container:
sudo docker build -t $(LABEL) .

run-container:
sudo docker run -p 8080:8080 $(LABEL)

clean-container:
sudo docker image prune
sudo docker container prune

check-container:
curl http://localhost:8080/bin/date
46 changes: 46 additions & 0 deletions README.md
@@ -0,0 +1,46 @@
# pandoc-as-a-service

## It does...

pandoc-as-a-service executes the command with options specified in the url, with STDIN from HTTP request body, and returns STDOUT in HTTP response body.

## It does not...

- authenticate request
- limit rate

## future work

see GitHub project : https://github.com/hrkt/command-as-a-service/projects

# How to run

1. execute server.

```
$ docker run -p 8080:8080 hrkt/pandoc-as-a-service
```

2. make HTTP POST request

```
$ curl "http://localhost:8080/usr/bin/pandoc?-f&markdown&-t&html" --dat-binary @testdata/sample.md
```

# dev how-to

## build container

```
$ make build-container
```

## run container

```
$ make run-container
```

# License
MIT

27 changes: 27 additions & 0 deletions app-settings.json
@@ -0,0 +1,27 @@
{
"dangerousMode": false,
"port": 8080,
"whitelist": [
"/bin/date",
"/bin/echo",
"/bin/hostname",
"/bin/sleep",
"/usr/bin/bc",
"/usr/bin/cal",
"/usr/bin/diff",
"/usr/bin/egrep",
"/usr/bin/grep",
"/usr/bin/gzcat",
"/usr/bin/head",
"/usr/bin/iconv",
"/usr/bin/man",
"/usr/bin/od",
"/usr/bin/sed",
"/usr/bin/seq",
"/usr/bin/sort",
"/usr/bin/tail",
"/usr/bin/tr",
"/usr/bin/wc",
"/usr/bin/pandoc"
]
}
11 changes: 11 additions & 0 deletions testdata/sample.md
@@ -0,0 +1,11 @@
# Level1

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

## Level2

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

### Level3

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

0 comments on commit cd4c129

Please sign in to comment.