node.jsdockerlanguagetool

Setting Up Stand-alone LanguageTool in Docker container


Im trying to setup LanguageTool as a standalone server as a Docker Container. So what I did is download the standalone system provided at -> https://languagetool.org/download/LanguageTool-stable.zip and put it in my project. I setup the docker-compose.yml file like so

version: '3'
services:
   grammar:
    build: ./services/grammar
    image: dev/grammar:1
    restart: always
    container_name: dev.grammar
    ports:
      - "8130:8130"

And I created the dockerfile inside the LanguageTool folder like so

FROM  ubuntu:18.04
WORKDIR /tmp

RUN apt-get update 
RUN apt-get install unzip

ADD https://languagetool.org/download/LanguageTool-stable.zip /tmp/LanguageTool-stable.zip

#RUN apt-get install -y unzip
RUN unzip /tmp/LanguageTool-stable.zip
RUN mv /tmp/LanguageTool-5.7 /usr/languagetool
  
CMD ["java", "-jar", "languagetool-server.jar", "--port", "8130", "--public", "--allow-origin", "'*'" ]
EXPOSE 8130

I have actually tried many iterations of the dockerfile like another example here

FROM debian:stretch

RUN set -ex \
    && mkdir -p /uploads /etc/apt/sources.list.d /var/cache/apt/archives/ \
    && export DEBIAN_FRONTEND=noninteractive \
    && apt-get clean \
    && apt-get update -y \
    && apt-get install -y \
        bash \
        curl \
        openjdk-8-jre-headless \
        unzip \
        libhunspell-1.4-0 \
        hunspell-de-at
 
ENV VERSION 5.7
COPY LanguageTool-$VERSION.zip /LanguageTool-$VERSION.zip

RUN unzip LanguageTool-$VERSION.zip \
    && rm LanguageTool-$VERSION.zip
 
WORKDIR /LanguageTool-$VERSION

CMD ["java", "-cp", "languagetool-server.jar", "org.languagetool.server.HTTPServer", "--port", "8130", "--public", "--allow-origin", "'*'" ]
EXPOSE 8130

But none of them seems to work. Please let me know what I am doing wrong here. Thanks in advance !!

Edit: Here is what my file/folder structure looks like here


Solution

  • I found the solution. Had to tinker around some configurations but I finally got it working. here is the dockerconfig file that worked for me.

    FROM debian:stretch
    
    RUN set -ex \
        && mkdir -p /uploads /etc/apt/sources.list.d /var/cache/apt/archives/ \
        && export DEBIAN_FRONTEND=noninteractive \
        && apt-get clean \
        && apt-get update -y \
        && apt-get install -y \
            bash \
            curl \
            openjdk-8-jre-headless \
            unzip \
            libhunspell-1.4-0 \
            hunspell-de-at
     
    ENV VERSION 5.1
    COPY LanguageTool-$VERSION.zip /LanguageTool-$VERSION.zip
    
    RUN unzip LanguageTool-$VERSION.zip \
        && rm LanguageTool-$VERSION.zip
     
    WORKDIR /LanguageTool-$VERSION
    
    CMD ["java", "-cp", "languagetool-server.jar", "org.languagetool.server.HTTPServer", "--port", "8130", "--public", "--allow-origin", "'*'" ]
    EXPOSE 8130