blob: e741cca385b3449c6ac4eb53de4be3af98192374 [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
Akrona2228232022-05-23 17:25:48 +020085COPY --from=builder /kustvakt/built/Kustvakt-lite.* /kustvakt/
Akron26ddf722020-08-11 15:39:32 +020086
87USER kustvakt
88
89EXPOSE 8089
90
Akron200aec42022-03-29 12:36:36 +020091ENTRYPOINT [ "java", "-jar" ]
92
93CMD [ "Kustvakt-lite.jar" ]
Akron26ddf722020-08-11 15:39:32 +020094
Akrona2228232022-05-23 17:25:48 +020095
96FROM openjdk:19-alpine AS kustvakt-full
97
98RUN addgroup -S korap && \
99 adduser -S kustvakt -G korap && \
100 mkdir kustvakt && \
101 chown -R kustvakt.korap /kustvakt
102
103WORKDIR /kustvakt
104
105RUN mkdir ./ldap \
106 mkdir ./client
107
108COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/
109COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/
110COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/
111
112USER kustvakt
113
114EXPOSE 8089
115
116ENTRYPOINT [ "java", "-jar" ]
117
118CMD [ "Kustvakt-full.jar" ]
119
120# docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full .
121# docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite .