aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile14
-rw-r--r--misc/init.sh13
-rw-r--r--readme.md60
3 files changed, 62 insertions, 25 deletions
diff --git a/Dockerfile b/Dockerfile
index 432be1d..81c855c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,10 +11,16 @@ RUN apt-get update && \
RUN curl --progress-bar "https://languagetool.org/download/LanguageTool-$VERSION.zip" |\
bsdtar -x -f -
-ADD misc/init.sh /init.sh
-ADD misc/ngram.sh /ngram.sh
+RUN adduser \
+ --home /LanguageTool-$VERSION \
+ --no-create-home languagetool
+
+ADD --chown=languagetool misc/init.sh /
+ADD --chown=languagetool misc/ngram.sh /
WORKDIR /LanguageTool-$VERSION
-CMD [ "sh", "/init.sh" ]
-USER nobody
+HEALTHCHECK --timeout=10s --start-period=5s \
+ CMD curl --fail --data "language=en-US&text=healthcheck test" http://localhost:8010/v2/check || exit 1
+CMD [ "bash", "/init.sh" ]
+USER languagetool
EXPOSE 8010
diff --git a/misc/init.sh b/misc/init.sh
index 5681037..dae150a 100644
--- a/misc/init.sh
+++ b/misc/init.sh
@@ -10,4 +10,17 @@ if [ -d "/ngrams" ]; then
fi
fi
+for var in ${!LT_*}; do
+ EXTRA_LT=true
+ echo "${var#'LT_'}="${!var} >> /tmp/config.properties
+done
+
+echo JAVAOPTIONS=$JAVAOPTIONS
+if [ "$EXTRA_LT" = true ]; then
+ EXTRAOPTIONS="${EXTRAOPTIONS} --config /tmp/config.properties"
+ echo config.properties:
+ echo "$(cat /tmp/config.properties)"
+fi
+echo EXTRAOPTIONS=$EXTRAOPTIONS
+
java ${JAVAOPTIONS} -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 8010 --public --allow-origin '*' ${EXTRAOPTIONS}
diff --git a/readme.md b/readme.md
index 039a512..6789ef7 100644
--- a/readme.md
+++ b/readme.md
@@ -20,42 +20,60 @@ The Server is running on port 8010, this port should exposed.
[...]
docker run --rm -p 8010:8010 ghcr.io/someone-stole-my-name/docker-languagetool
-Or you run it in background via `-d` option.
+Route information can be found at https://languagetool.org/http-api/swagger-ui/#/default, an easy route to test that it's running is `/v2/languages`.
-Run with minimum rights and RAM limit
+## Configuration
- docker run --name languagetool \
- --cap-drop=ALL \
- --user=65534:65534 \
- --read-only \
- --mount type=bind,src=/tmp/languagetool/tmp,dst=/tmp \
- -p 127.0.0.1:8010:8010 \
- --memory 412m --memory-swap 500m \
- -e JAVAOPTIONS="-Xmx382M" \
- ghcr.io/someone-stole-my-name/docker-languagetool:latest
+### Java heap size
+You can set any Java related option using the `JAVAOPTIONS` environment variable.
-Route information can be found at https://languagetool.org/http-api/swagger-ui/#/default, an easy route to test that it's running is `/v2/languages`.
+ docker run --rm -it -p 8010:8010 -e JAVAOPTIONS="-Xmx382M" ghcr.io/someone-stole-my-name/docker-languagetool:latest
+
+### HTTPServerConfig
+
+Any environment variable prefixed with `LT_` is interpreted as an [HTTPServerConfig] option.
-## ngram support
+ docker run --rm -it -p 8010:8010 -p 9301:9301 \
+ -e LT_prometheusMonitoring=true \
+ ghcr.io/someone-stole-my-name/docker-languagetool:latest
+ [...]
+
+ curl -s localhost:9301 | grep -v '^\s*$\|^\s*\#' (k8s-pro)
+ languagetool_check_matches_total{language="en",mode="ALL",} 1.0
+ languagetool_threadpool_queue_size{pool="lt-server-thread",} 0.0
+ [...]
-To support [ngrams] you need an additional volume or directory mounted to the
-`/ngrams` directory. For that add a `-v` to the `docker run` command.
+### n-gram dataset support
+
+To support [ngrams] you need an additional volume or directory mounted to the `/ngrams` directory.
docker run ... -v /foo:/ngrams ...
-[ngrams]: http://wiki.languagetool.org/finding-errors-using-n-gram-data
-### Manual
+### Automatic download
-Download English ngrams with the commands:
+This image can take care of the initial download of any ngram supported language as well as updates.
+Mount a directory or volume to `/ngrams` and use the `NGRAM_LANGUAGES` environment variable to pass a comma separated string with languages:
+
+ docker run ... -v /path/to/ngrams:/ngrams -e NGRAM_LANGUAGES="en,es" ...
+
+### Manual download
+
+Download and unzip any language with the commands:
mkdir ngrams
wget https://languagetool.org/download/ngram-data/ngrams-en-YYYYMMDD.zip
(cd ngrams && unzip ../ngrams-en-YYYYMMDD.zip)
rm -f ngrams-en-YYYYMMDD.zip
-### Automatically
+It is important that the directory structure ends up looking like:
-Mount a directory or volume to `/ngrams` and use the `NGRAM_LANGUAGES` variable to pass a comma separated string with languages:
+ ngrams/
+ en/
+ ...
+ es/
+ ...
- docker run ... -v /path/to/ngrams:/ngrams -e NGRAM_LANGUAGES="en,es" ...
+
+[ngrams]: http://wiki.languagetool.org/finding-errors-using-n-gram-data
+[HTTPServerConfig]: https://languagetool.org/development/api/org/languagetool/server/HTTPServerConfig.html