Skip to content

Commit

Permalink
build docker from local source
Browse files Browse the repository at this point in the history
Former-commit-id: 9338013
  • Loading branch information
de-code committed Apr 19, 2018
1 parent f5ee604 commit 3e45465
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 32 deletions.
70 changes: 70 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/.git
/bin
/build

**/build
**/target

target
grobid-home/tmp
.DS_Store
Thumbs.db
.project
.settings
.classpath
.idea
#.gradle
#gradle
**/build
*/out/
*.iml
*.log
*.log.*
*.old
tei-alt
raw-alt
/log
/logs

dependency-reduced-pom.xml

grobid-core/dependency-reduced-pom.xml

grobid-core/src/test/resources/org/grobid/core/annotations/resTeiStAXParser/out.tei.xml

grobid-home/models/affiliation-address/model.crf.old

grobid-home/models/name/header/model.crf.old

build.xml

*/maven-build.properties
*/maven-build.xml
maven-build.xml
release.properties

grobid-quantities
grobid-dictionaries
grobid-ner
grobid-bio
grobid-istex
grobid-astro
grobid-chem
grobid-books
grobid-smecta
grobid-example
grobid-test-ant
grobid-home/models/quantities
grobid-home/models/dictionaries-lexical-entries
grobid-home/models/units
grobid-home/models/bio
grobid-home/models/ner
grobid-home/models/nerfr
grobid-home/models/nersense
grobid-home/models/astro
grobid-home/models/lexical-entry/*
grobid-home/models/*lexical-entry*
grobid-home/models/lexical-entry/model.wapiti
grobid-home/models/dictionary*
grobid-home/models/dictionaries*

79 changes: 47 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,75 @@
# To connect to the container with a bash shell
# > docker exec -i -t {container_name} /bin/bash

# -------------------
# build builder image
# -------------------
FROM openjdk:8-jdk as builder

MAINTAINER Luca Foppiano <[email protected]>, Patrice Lopez <[email protected]>

ARG GROBID_VERSION

USER root

RUN apt-get update && \
apt-get -y --no-install-recommends install libxml2 git
apt-get -y --no-install-recommends install libxml2

RUN cd /opt && \
git clone https://github.com/kermitt2/grobid.git grobid-source && \
cd /opt/grobid-source && \
git checkout ${GROBID_VERSION} && \
./gradlew clean assemble
WORKDIR /opt/grobid-source

FROM openjdk:8-jre-slim
RUN mkdir -p .gradle
VOLUME /opt/grobid-source/.gradle

ARG GROBID_VERSION
# gradle
COPY gradle/ ./gradle/
COPY gradlew ./
COPY gradle.properties ./
COPY build.gradle ./
COPY settings.gradle ./

MAINTAINER Luca Foppiano <[email protected]>, Patrice Lopez <[email protected]>
# source
COPY grobid-home/ ./grobid-home/
COPY grobid-core/ ./grobid-core/
COPY grobid-service/ ./grobid-service/
COPY grobid-trainer/ ./grobid-trainer/

LABEL \
org.label-schema.name="Grobid" \
org.label-schema.description="Image with GROBID service" \
org.label-schema.url="https://github.com/kermitt2/grobid" \
org.label-schema.version=${GROBID_VERSION}
RUN ./gradlew clean assemble

ENV JAVA_OPTS=-Xmx4g

COPY --from=builder /opt/grobid-source/grobid-service/build/distributions/grobid-service-${GROBID_VERSION}.zip /opt
COPY --from=builder /opt/grobid-source/grobid-home/build/distributions/grobid-home-${GROBID_VERSION}.zip /opt
# -------------------
# build runtime image
# -------------------
FROM openjdk:8-jre-slim

RUN apt-get update && \
apt-get -y --no-install-recommends install libxml2

WORKDIR /opt

RUN unzip -o /opt/grobid-service-${GROBID_VERSION}.zip -d /opt/grobid && \
mv /opt/grobid/grobid-service-${GROBID_VERSION} /opt/grobid/grobid-service
COPY --from=builder /opt/grobid-source/grobid-service/build/distributions/grobid-service-*.zip ./grobid-service.zip
COPY --from=builder /opt/grobid-source/grobid-home/build/distributions/grobid-home-*.zip ./grobid-home.zip

RUN unzip /opt/grobid-home-${GROBID_VERSION}.zip -d /opt/grobid && \
mkdir -p /opt/grobid/grobid-home/tmp
RUN unzip -o ./grobid-service.zip -d ./grobid && \
mv ./grobid/grobid-service-* ./grobid/grobid-service

# Workaround for version 0.5.1
#RUN mkdir /opt/grobid/grobid-service/config
#ADD ./grobid-service/config /opt/grobid/grobid-service/config
RUN unzip ./grobid-home.zip -d ./grobid && \
mkdir -p /opt/grobid/grobid-home/tmp

RUN apt-get update && \
apt-get -y --no-install-recommends install \
libxml2
RUN rm *.zip

VOLUME ["/opt/grobid/grobid-home/tmp"]

WORKDIR /opt/grobid

ENV JAVA_OPTS=-Xmx4g

CMD ["./grobid-service/bin/grobid-service", "server", "grobid-service/config/config.yaml"]

ARG GROBID_VERSION

LABEL \
authors="Luca Foppiano <[email protected]>, Patrice Lopez <[email protected]>" \
org.label-schema.name="Grobid" \
org.label-schema.description="Image with GROBID service" \
org.label-schema.url="https://github.com/kermitt2/grobid" \
org.label-schema.version=${GROBID_VERSION}

## Docker tricks:

# - remove all stopped containers
Expand All @@ -74,4 +89,4 @@ CMD ["./grobid-service/bin/grobid-service", "server", "grobid-service/config/con
# > docker rmi $(docker images | grep "^<none>" | awk "{print $3}")

# - "Cannot connect to the Docker daemon. Is the docker daemon running on this host?"
# > docker-machine restart
# > docker-machine restart

0 comments on commit 3e45465

Please sign in to comment.