diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5ec702 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM alpine:3.8 as builder + +RUN apk update && \ + apk add git wget openjdk8-jre-base py2-pip py2-curl && \ + pip install setuptools + +# install geturl script to retrieve the most current download URL of CoreNLP +WORKDIR /opt +RUN git clone https://github.com/arne-cl/grepurl.git +WORKDIR /opt/grepurl +RUN python setup.py install + +# install latest CoreNLP release +WORKDIR /opt +RUN wget $(grepurl -r 'zip$' -a http://stanfordnlp.github.io/CoreNLP/) && \ + unzip stanford-corenlp-full-*.zip && \ + mv $(ls -d stanford-corenlp-full-*/) corenlp && rm *.zip + +# install latest English language model +ARG LANGUAGE +WORKDIR /opt/corenlp +RUN wget $(grepurl -r "$LANGUAGE.*jar$" -a http://stanfordnlp.github.io/CoreNLP | head -n 1) + + +# only keep the things we need to run and test CoreNLP +FROM alpine:3.8 + +RUN apk update && apk add openjdk8-jre-base py3-pip && \ + pip3 install pytest pexpect requests + +WORKDIR /opt/corenlp +COPY --from=builder /opt/corenlp . + +ENV JAVA_XMX 4g +ENV PORT 9000 +EXPOSE $PORT + +CMD java -Xmx$JAVA_XMX -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..143bba4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3' +services: + corenlp-english: + build: + context: . + args: + - LANGUAGE=english + ports: + - 9001:9000 + corenlp-spanish: + build: + context: . + args: + - LANGUAGE=spanish + ports: + - 9002:9000 + demo-spanish: + image: nginx:alpine + volumes: + - ./examples/browser/tree:/usr/share/nginx/html + - ./dist/index.browser.min.js:/usr/share/nginx/html/corenlp.min.js + ports: + - 8080:80 diff --git a/examples/browser/tree/tree.js b/examples/browser/tree/tree.js index 99aafc2..537d135 100644 --- a/examples/browser/tree/tree.js +++ b/examples/browser/tree/tree.js @@ -1,4 +1,4 @@ -const connector = new CoreNLP.ConnectorServer({ dsn: 'http://corenlp.run' }); +const connector = new CoreNLP.ConnectorServer({ dsn: 'http://localhost:9002' }); const props = new CoreNLP.Properties({ annotators: 'tokenize,ssplit,pos,lemma,ner,parse,depparse' }); const inputSentence = document.getElementById('input-sentence'); const info = document.getElementById('info');