blob: bade66b8f37a25b1d2f5ab85c3252499c966b72a [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
62# Cleanup
Akrond0ca9902023-05-17 08:57:07 +020063RUN rm -r full && \
64 rm -r sample-index && \
65 rm -r wiki-index
Akron26ddf722020-08-11 15:39:32 +020066
67RUN apk del git \
68 maven
69
70RUN cd ${M2_HOME} && rm -r .m2
71
Akrona2228232022-05-23 17:25:48 +020072FROM openjdk:19-alpine AS kustvakt-lite
Akron26ddf722020-08-11 15:39:32 +020073
74RUN addgroup -S korap && \
75 adduser -S kustvakt -G korap && \
76 mkdir kustvakt && \
77 chown -R kustvakt.korap /kustvakt
78
79WORKDIR /kustvakt
80
Akronf9c12d12022-12-05 14:24:08 +010081COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/
82COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/
83COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akron26ddf722020-08-11 15:39:32 +020084
85USER kustvakt
86
87EXPOSE 8089
88
Akron200aec42022-03-29 12:36:36 +020089ENTRYPOINT [ "java", "-jar" ]
90
91CMD [ "Kustvakt-lite.jar" ]
Akron26ddf722020-08-11 15:39:32 +020092
Akrona2228232022-05-23 17:25:48 +020093FROM openjdk:19-alpine AS kustvakt-full
94
95RUN addgroup -S korap && \
96 adduser -S kustvakt -G korap && \
97 mkdir kustvakt && \
98 chown -R kustvakt.korap /kustvakt
99
100WORKDIR /kustvakt
101
102RUN mkdir ./ldap \
103 mkdir ./client
104
105COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/
106COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/
107COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/
Akronf9c12d12022-12-05 14:24:08 +0100108COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akrona2228232022-05-23 17:25:48 +0200109
110USER kustvakt
111
112EXPOSE 8089
113
114ENTRYPOINT [ "java", "-jar" ]
115
116CMD [ "Kustvakt-full.jar" ]
117
118# docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full .
119# docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite .