-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile
123 lines (97 loc) · 3.62 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
ARG ENTITY_FISHING_PORT=8090
ARG ENTITY_FISHING_PORT_MONITOR=8091
ARG BUILD_VERSION=0.0.6
# -------------
# builder image
# -------------
#FROM openjdk:8u275-jdk as builder
FROM openjdk:17-jdk-slim as builder
USER root
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
RUN apt-get update && \
apt-get -y --no-install-recommends install unzip wget git
# Final upgrade + clean
RUN apt-get update -y && \
apt-get clean all -y
WORKDIR /opt/
# install GROBID
RUN wget --tries=10 --read-timeout=10 https://github.com/kermitt2/grobid/archive/refs/tags/0.8.1.zip
RUN unzip -o 0.8.1.zip && mv grobid-* grobid
WORKDIR /opt/grobid
# cleaning unused native libraries before packaging
RUN rm -rf grobid-home/pdf2xml
RUN rm -rf grobid-home/pdfalto/lin-32
RUN rm -rf grobid-home/pdfalto/mac-64
RUN rm -rf grobid-home/pdfalto/win-*
RUN rm -rf grobid-home/lib/lin-32
RUN rm -rf grobid-home/lib/win-*
RUN rm -rf grobid-home/lib/mac-64
RUN rm -rf ../0.8.1.zip
# cleaning DeLFT models
RUN rm -rf grobid-home/models/*-BidLSTM_CRF*
# building grobid
RUN ./gradlew clean assemble --no-daemon --info --stacktrace
RUN chmod -R 755 /opt/grobid/grobid-home/pdfalto
# install grobid-ner
RUN git clone https://github.com/kermitt2/grobid-ner.git
WORKDIR /opt/grobid/grobid-ner
RUN ./gradlew copyModels
RUN ./gradlew clean install --no-daemon --info --stacktrace
# install entity-fishing
WORKDIR /opt/
# gradle
COPY gradle/ ./entity-fishing/gradle/
COPY gradlew ./entity-fishing/
COPY gradle.properties ./entity-fishing/
COPY build.gradle ./entity-fishing/
COPY settings.gradle ./entity-fishing/
COPY data/ ./entity-fishing/data/
COPY lib/ ./entity-fishing/lib/
COPY src/ ./entity-fishing/src/
WORKDIR /opt/entity-fishing
RUN ./gradlew clean install -x test
# -------------
# runtime image
# -------------
FROM openjdk:11-jre-slim
RUN apt-get update && \
apt-get -y --no-install-recommends install libxml2 libfontconfig htop nano
# Final upgrade + clean
RUN apt-get update -y && \
apt-get clean all -y
# Add Tini
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "-s", "--"]
WORKDIR /opt/grobid
COPY --from=builder /opt/grobid .
WORKDIR /opt/entity-fishing
COPY --from=builder /opt/entity-fishing .
# Hack m2 repository
COPY --from=builder /root/.m2/repository /root/.m2/repository
ADD lib/com /root/.m2/repository/com
ADD lib/fr /root/.m2/repository/fr
ADD lib/org /root/.m2/repository/or
# trigger gradle wrapper install
RUN chmod -R 755 /opt/entity-fishing/gradlew
RUN ./gradlew --no-daemon processResources classes dependencies -x compileJava
# More hack: Simulate gradlew in WORKDIR to get possible still missing prerequisites dependency files
# Add timeout + exit0 to prevent infinite interactive mode
RUN timeout 120s ./gradlew --no-daemon run -x compileJava || true
# Expose port ENTITY_FISHING_PORT (default 8090 and 8091)
EXPOSE ${ENTITY_FISHING_PORT}
EXPOSE ${ENTITY_FISHING_PORT_MONITOR}
# Start server (skip compile, we only have a JRE in this image)
# entity-fishing server will be accessible at http://<SERVER ADDRESS>:${ENTITY_FISHING_PORT}
CMD ["./gradlew", "--no-daemon", "run", "-x", "compileJava", "-x", "processResources", "-x", "classes"]
# Labels
LABEL \
authors="The contributors" \
org.label-schema.name="entity-fishing" \
org.label-schema.description="Image for entity-fishing container" \
org.label-schema.url="https://github.com/kermitt2/entity-fishing" \
org.label-schema.version=${BUILD_VERSION}
# Thanks to Guillaume Karcher (guillaume.karcher@kairntech.com) for his help writing this dockerfile.