From d0ed6a49c3a778363666e2a406b7fa407959a962 Mon Sep 17 00:00:00 2001 From: novalagung Date: Fri, 17 Apr 2020 04:21:22 +0700 Subject: [PATCH] feat: add a dockerfile and readme documentation --- Dockerfile | 20 ++++++++++++++++++++ README.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..a432cbc1a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# build the epubcheck.jar file +FROM maven:slim as builder + +WORKDIR /app +COPY . . +RUN mvn clean install + +# prepare runner for epubcheck.jar execution +FROM openjdk:slim + +WORKDIR /app +COPY --from=builder /app . +RUN echo '#!/bin/bash\n java -jar /app/target/epubcheck.jar "${@:1}"\n' > entrypoint.sh +RUN chmod +x entrypoint.sh + +ENV DATA_PATH=/data +WORKDIR ${DATA_PATH} +VOLUME ${DATA_PATH} + +ENTRYPOINT [ "/app/entrypoint.sh" ] diff --git a/README.md b/README.md index 263d080ba..1670d08d1 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ Historical archives of discussions prior to October 2017 are stored at the old [ ## Building EPUBCheck +### Build from sources + To build epubcheck from the sources you need Java Development Kit (JDK) 1.7 or above and [Apache Maven](http://maven.apache.org/) 3.0 or above installed. Build and run tests: @@ -44,6 +46,36 @@ $ mvn clean install ``` Will copy `*.jar` files and packages to `target/` folder... +### Build using docker + +To build the epubcheck using docker, use the build command below: + +```bash +$ docker build . -t epubcheck +``` + +To run the epubcheck image as container, use example command below: + +```bash +# one directory in the host need to be mapped (using docker volume) to /data path +# within container. the particular path will be used as a bridge to enable access +# over the epub file or the generated output file between host and container. +$ docker run -it --rm -v :/data epubcheck --help +$ docker run -it --rm -v :/data epubcheck --help [OPTIONS] + +# example 1: +# execute an epub check over a file located in /home/username/file.epub on the host. +# the output will be printed to the console +$ docker run -it --rm -v /home/username:/data epubcheck file.epub --out - + +# example 2: +# execute an epub check over a file, and then generate an output file +# in /data/output.json within container. +# since /data is mapped via volume, then the generated file will be accessible +# from /home/username/output.json in the host +$ docker run - --rm -v /home/username:/data epubcheck file.epub --mode opf --profile dict --json output.json +``` + ## Credits Most of the EPUBCheck functionality comes from the schema validation tool [Jing](http://www.thaiopensource.com/relaxng/jing.html) and schemas that were developed by [IDPF](http://www.idpf.org/) and [DAISY](http://www.daisy.org/). Initial EPUBCheck development was largely done at [Adobe Systems](http://www.adobe.com/).