Mercurial > hg > digilib
changeset 1712:f63a888473e3
Merge pull request #19 from robcast/dockerize
README for Docker hub and configuration options for container.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 18 Feb 2019 18:34:26 +0100 |
parents | 367ae3da4f20 (current diff) 439aefc7a6c9 (diff) |
children | af7a0dedc89e |
files | |
diffstat | 4 files changed, 138 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/README.md Sun Feb 17 19:25:52 2019 +0100 +++ b/README.md Mon Feb 18 18:34:26 2019 +0100 @@ -30,6 +30,7 @@ * [Source code](https://github.com/robcast/digilib) * [Issue tracker](https://github.com/robcast/digilib/issues) +* [Docker images](https://hub.docker.com/r/robcast/digilib) * Daily built [WAR files](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/) * Daily built [Javadoc](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/javadoc/) * [Maven repository](http://it-dev.mpiwg-berlin.mpg.de/maven-repo/) @@ -58,6 +59,6 @@ `mvn jetty:run-exploded --projects webapp` - and watch digilib at http://localhost:8080/digilib/digilib.html + and open http://localhost:8080/digilib/digilib.html in your browser. or follow the build and install instructions on the [documentation pages](https://robcast.github.io/digilib/).
--- a/build/docker/Dockerfile Sun Feb 17 19:25:52 2019 +0100 +++ b/build/docker/Dockerfile Mon Feb 18 18:34:26 2019 +0100 @@ -2,13 +2,20 @@ FROM maven:3-jdk-11 AS buildstage WORKDIR /usr/src/digilib COPY . /usr/src/digilib/ -RUN mvn package +ARG MVN_ARGS +# build digilib using maven +RUN mvn $MVN_ARGS package # remove the war file so we don't copy it in the next stage RUN rm /usr/src/digilib/webapp/target/digilib-webapp-*.war # runnable container stage FROM tomcat:9-jre11 AS runstage -# remove tomcat default webapps -RUN rm -r /usr/local/tomcat/webapps/* +# copy entry script +COPY build/docker/entrypoint.sh /entrypoint.sh +# remove tomcat default webapps and set entrypoint +RUN rm -r /usr/local/tomcat/webapps/* \ + && chmod 755 /entrypoint.sh # copy digilib from build image COPY --from=buildstage /usr/src/digilib/webapp/target/digilib-webapp-* /usr/local/tomcat/webapps/digilib/ + +ENTRYPOINT ["/entrypoint.sh"]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build/docker/README.md Mon Feb 18 18:34:26 2019 +0100 @@ -0,0 +1,91 @@ +# digilib + + + +A Docker container for the [digilib image server](https://robcast.github.io/digilib/). + +digilib is a [IIIF API](https://iiif.io) compliant image server written in Java: + * Documentation: https://robcast.github.io/digilib/ + * Issues: https://github.com/robcast/digilib/issues + * Source code: https://github.com/robcast/digilib + +## Supported tags + + * **release-x.y.z**: Tagged release builds. + * **snapshot**: unstable daily builds from the `master` branch. + +## Dependencies + +The digilib runtime image builds on the [tomcat:9-jre11](https://hub.docker.com/_/tomcat) image. + +## How to use this image + +Quick try-out using built-in images: +``` +docker run --rm -p 8080:8080 robcast/digilib +``` +Then open https://localhost:8080/digilib/digilib.html in your browser. + +To use your own images in the directory `/your/image/path` on your host system: +``` +docker run --rm \ + -p 8080:8080 \ + --name digilib \ + -e BASEDIR_LIST="/var/lib/images" \ + -v /your/image/path:/var/lib/images \ + robcast/digilib +``` + +## Available parameters for the container + +You can set the values of the most important digilib configuration parameters as environment variables +using the `-e` option of `docker run`. For more information check the +[digilib-config documentation](https://robcast.github.io/digilib/digilib-config.html). + + * BASEDIR_LIST: The list of directories where images are searched. + + * DEFAULT_QUALITY: The default interpolation quality (0: do not use interpolation (worst), + 1: use linear interpolation, + 2: use bilinear interpolation and blur-before-scale (best, default)) + + * MAX_IMAGE_SIZE: The maximum size of delivered images as pixel area, 40000 means up to 200x200 or 100x400, +0 (default) means no limit. + + * SENDFILE_ALLOWED: Is sending whole image files with mo=file allowed (default: "true")? + + * WORKER_THREADS: Number of parallel working threads (default: 2). + + * MAX_WAITING_THREADS: Maximum number of waiting requests in queue (default: 20). + + * IIIF_PREFIX: The URL prefix (after Scaler) that leads to the IIIF API (default: "IIIF") + +## Using your own `digilib-config.xml` + +If you need more control over your [digilib configuration](https://robcast.github.io/digilib/digilib-config.html) +then you can supply your own `digilib-config.xml` file by mounting it +to `/usr/local/tomcat/webapps/digilib/WEB-INF/digilib-config.xml` in the container: +``` +docker run --rm \ + -p 8080:8080 \ + --name digilib \ + -v digilib-config.xml:/usr/local/tomcat/webapps/digilib/WEB-INF/digilib-config.xml + -v /your/image/path:/var/lib/images \ + robcast/digilib +``` + +Note: when you use your own config file you can not use the predefined parameters described above. + +## Building your own container image + +You can build your own digilib container image from the digilib sources: +``` +git clone https://github.com/robcast/digilib.git +cd digilib +docker build -f build/docker/Dockerfile -t mydigilib:latest . +``` + +You can supply additional options to Maven during the build process using the `MVM_ARGS` build parameter: +``` +docker build -f build/docker/Dockerfile -t mydigilib:latest --build-arg MVN_ARGS="-Piiif-presentation" . +``` +See the [digilib build documentation](https://robcast.github.io/digilib/build-maven.html) for more information.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build/docker/entrypoint.sh Mon Feb 18 18:34:26 2019 +0100 @@ -0,0 +1,35 @@ +#!/bin/sh + +DL_CONFIG=webapps/digilib/WEB-INF/digilib-config.xml + +if [ ! -f $DL_CONFIG ] ; then +# generate digilib config using ENV +cat <<EOF > $DL_CONFIG +<?xml version="1.0" encoding="UTF-8"?> +<digilib-config> + <!-- A list of directories where images are searched --> + <parameter name="basedir-list" value="${BASEDIR_LIST:-/usr/local/tomcat/webapps/digilib/sample-images}" /> + + <!-- The default interpolation quality (0-2). --> + <parameter name="default-quality" value="${DEFAULT_QUALITY:-2}" /> + + <!-- The maximum size of delivered images as pixel area, 40000 means up to 200x200 or 100x400, 0 means no limit. --> + <parameter name="max-image-size" value="${MAX_IMAGE_SIZE:-0}" /> + + <!-- is sending whole image files with mo=file allowed? --> + <parameter name="sendfile-allowed" value="${SENDFILE_ALLOWED:-true}" /> + + <!-- number of working threads --> + <parameter name="worker-threads" value="${WORKER_THREADS:-2}" /> + + <!-- number of waiting requests in queue --> + <parameter name="max-waiting-threads" value="${MAX_WAITING_THREADS:-20}" /> + + <!-- The prefix (after Scaler) that leads to the IIIF API.--> + <parameter name="iiif-prefix" value="${IIIF_PREFIX:-IIIF}" /> +</digilib-config> +EOF +fi + +# run the command given in the origin Dockerfile at CMD +exec catalina.sh run