我试图设置LanguageTool作为一个独立的服务器作为Docker容器。所以我所做的就是下载在->https://languagetool.org/download/LanguageTool-stable.zip并把它放到我的项目中。我设置了docker-compose。Yml文件如下
version: '3'
services:
grammar:
build: ./services/grammar
image: dev/grammar:1
restart: always
container_name: dev.grammar
ports:
- "8130:8130"
然后在LanguageTool文件夹中创建dockerfile,如下所示
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
我实际上已经尝试了许多迭代的dockerfile就像这里的另一个例子
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
但是它们似乎都不起作用。请让我知道我做错了什么。提前感谢!!
编辑:这是我的文件/文件夹结构看起来像这里
我找到了解决方案。不得不修改一些配置,但我终于让它工作了。这是为我工作的dockerconfig文件。
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