blob: 35c2c544b66a4b713fd9ffa3262ca1aa23cd9ec9 [file] [log] [blame]
Akron26ddf722020-08-11 15:39:32 +02001# Use alpine linux as base image
Marc Kupietzaf06c462022-11-17 17:25:35 +01002FROM openjdk:19-alpine as builder
Akron26ddf722020-08-11 15:39:32 +02003
4# Copy repository respecting .dockerignore
5COPY . /kustvakt
6
7WORKDIR /kustvakt
8
9RUN apk update && \
10 apk add --no-cache git \
11 maven
12
13RUN git config --global user.email "korap+docker@ids-mannheim.de" && \
14 git config --global user.name "Docker"
15
16# Install Koral
17RUN mkdir Koral && git clone https://github.com/KorAP/Koral.git Koral && \
18 cd Koral && \
19 git checkout master && \
20 mvn clean install
21
22RUN rm -r Koral
23
24# Install Krill
Akron200aec42022-03-29 12:36:36 +020025RUN mkdir built && \
26 git clone https://github.com/KorAP/Krill.git Krill && \
Akron26ddf722020-08-11 15:39:32 +020027 cd Krill && \
28 git checkout master && \
Akron200aec42022-03-29 12:36:36 +020029 mvn clean install && \
30 mvn -Dmaven.test.skip=true package && \
31 mv target/Krill-Indexer.jar /kustvakt/built/Krill-Indexer.jar
Akron26ddf722020-08-11 15:39:32 +020032
33RUN rm -r Krill
34
Akron26ddf722020-08-11 15:39:32 +020035# Package lite
Akrond0ca9902023-05-17 08:57:07 +020036RUN cd full && \
37 mvn clean package -P lite && \
Akron26ddf722020-08-11 15:39:32 +020038 find target/Kustvakt-lite-*.jar -exec mv {} ../built/Kustvakt-lite.jar ';'
39
Akrond0ca9902023-05-17 08:57:07 +020040RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' full/src/main/resources/kustvakt-lite.conf \
Akron26ddf722020-08-11 15:39:32 +020041 > built/kustvakt-lite.conf
42
Akrona2228232022-05-23 17:25:48 +020043# Package full
44RUN cd full && \
Akrond0ca9902023-05-17 08:57:07 +020045 mvn clean package -DskipTests=true && \
Akrona2228232022-05-23 17:25:48 +020046 find target/Kustvakt-full-*.jar -exec mv {} ../built/Kustvakt-full.jar ';'
47
48RUN cat full/src/main/resources/kustvakt.conf | \
49 sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' | \
50 sed 's!\(ldap\.config\s*=\).\+!\1\/kustvakt\/ldap\/ldap\.conf!' | \
51 sed 's!\(oauth2\.initial\.super\.client\s*=\).\+!\1\/true!' | \
52 sed '$ a oauth2.initial.super.client = true' \
53 > built/kustvakt.conf
54
55RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \
56 full/src/main/resources/embedded-ldap-example.conf \
57 > built/ldap.conf
58
59RUN cat full/src/main/resources/example-users.ldif \
60 > built/ldap.ldif
61
Akron26ddf722020-08-11 15:39:32 +020062RUN apk del git \
63 maven
64
65RUN cd ${M2_HOME} && rm -r .m2
66
Akrone848ec02023-10-24 15:22:49 +020067# Cleanup
68RUN rm -r full && \
69 rm -r wiki-index
70
71FROM busybox:latest AS example-index
72
73WORKDIR /kustvakt
74
75RUN addgroup -S korap && \
76 adduser -S kustvakt -G korap && \
77 mkdir kustvakt && \
78 chown -R kustvakt.korap /kustvakt
79
80COPY --from=builder /kustvakt/sample-index /kustvakt/index
81
82USER kustvakt
83
84CMD ["sh"]
85
Akrona2228232022-05-23 17:25:48 +020086FROM openjdk:19-alpine AS kustvakt-lite
Akron26ddf722020-08-11 15:39:32 +020087
88RUN addgroup -S korap && \
89 adduser -S kustvakt -G korap && \
90 mkdir kustvakt && \
91 chown -R kustvakt.korap /kustvakt
92
93WORKDIR /kustvakt
94
Akronf9c12d12022-12-05 14:24:08 +010095COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/
96COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/
97COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akron26ddf722020-08-11 15:39:32 +020098
99USER kustvakt
100
101EXPOSE 8089
102
Akron200aec42022-03-29 12:36:36 +0200103ENTRYPOINT [ "java", "-jar" ]
104
105CMD [ "Kustvakt-lite.jar" ]
Akron26ddf722020-08-11 15:39:32 +0200106
Akrona2228232022-05-23 17:25:48 +0200107FROM openjdk:19-alpine AS kustvakt-full
108
109RUN addgroup -S korap && \
110 adduser -S kustvakt -G korap && \
111 mkdir kustvakt && \
112 chown -R kustvakt.korap /kustvakt
113
114WORKDIR /kustvakt
115
116RUN mkdir ./ldap \
117 mkdir ./client
118
119COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/
120COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/
121COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/
Akronf9c12d12022-12-05 14:24:08 +0100122COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akrona2228232022-05-23 17:25:48 +0200123
124USER kustvakt
125
126EXPOSE 8089
127
128ENTRYPOINT [ "java", "-jar" ]
129
130CMD [ "Kustvakt-full.jar" ]
131
132# docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full .
133# docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite .
Akrone848ec02023-10-24 15:22:49 +0200134# docker build -f Dockerfile -t korap/example-index:{nr} --target example-index .