blob: e3cd76861bce5e4b2225430bf09724e1c1850f88 [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
35# Install Kustvakt core
Marc Kupietzaf06c462022-11-17 17:25:35 +010036RUN mvn -f core/pom.xml clean install
Akron26ddf722020-08-11 15:39:32 +020037
38# Package lite
Akron200aec42022-03-29 12:36:36 +020039RUN cd lite && \
Akron26ddf722020-08-11 15:39:32 +020040 mvn clean package && \
41 find target/Kustvakt-lite-*.jar -exec mv {} ../built/Kustvakt-lite.jar ';'
42
43RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' lite/src/main/resources/kustvakt-lite.conf \
44 > built/kustvakt-lite.conf
45
Akrona2228232022-05-23 17:25:48 +020046# Package full
47RUN cd full && \
48 mvn clean package && \
49 find target/Kustvakt-full-*.jar -exec mv {} ../built/Kustvakt-full.jar ';'
50
51RUN cat full/src/main/resources/kustvakt.conf | \
52 sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' | \
53 sed 's!\(ldap\.config\s*=\).\+!\1\/kustvakt\/ldap\/ldap\.conf!' | \
54 sed 's!\(oauth2\.initial\.super\.client\s*=\).\+!\1\/true!' | \
55 sed '$ a oauth2.initial.super.client = true' \
56 > built/kustvakt.conf
57
58RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \
59 full/src/main/resources/embedded-ldap-example.conf \
60 > built/ldap.conf
61
62RUN cat full/src/main/resources/example-users.ldif \
63 > built/ldap.ldif
64
65# Cleanup
Akron26ddf722020-08-11 15:39:32 +020066RUN rm -r core && \
67 rm -r full && \
68 rm -r lite && \
69 rm -r sample-index
70
71RUN apk del git \
72 maven
73
74RUN cd ${M2_HOME} && rm -r .m2
75
Akrona2228232022-05-23 17:25:48 +020076FROM openjdk:19-alpine AS kustvakt-lite
Akron26ddf722020-08-11 15:39:32 +020077
78RUN addgroup -S korap && \
79 adduser -S kustvakt -G korap && \
80 mkdir kustvakt && \
81 chown -R kustvakt.korap /kustvakt
82
83WORKDIR /kustvakt
84
Akronf9c12d12022-12-05 14:24:08 +010085COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/
86COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/
87COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akron26ddf722020-08-11 15:39:32 +020088
89USER kustvakt
90
91EXPOSE 8089
92
Akron200aec42022-03-29 12:36:36 +020093ENTRYPOINT [ "java", "-jar" ]
94
95CMD [ "Kustvakt-lite.jar" ]
Akron26ddf722020-08-11 15:39:32 +020096
Akrona2228232022-05-23 17:25:48 +020097
98FROM openjdk:19-alpine AS kustvakt-full
99
100RUN addgroup -S korap && \
101 adduser -S kustvakt -G korap && \
102 mkdir kustvakt && \
103 chown -R kustvakt.korap /kustvakt
104
105WORKDIR /kustvakt
106
107RUN mkdir ./ldap \
108 mkdir ./client
109
110COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/
111COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/
112COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/
Akronf9c12d12022-12-05 14:24:08 +0100113COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akrona2228232022-05-23 17:25:48 +0200114
115USER kustvakt
116
117EXPOSE 8089
118
119ENTRYPOINT [ "java", "-jar" ]
120
121CMD [ "Kustvakt-full.jar" ]
122
123# docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full .
124# docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite .