blob: 775bc9d21c5048f3bfc4abce24e123617cecca74 [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 \
Akron8ae24622023-10-13 09:44:55 +020011 curl \
12 perl \
13 wget \
Akron26ddf722020-08-11 15:39:32 +020014 maven
15
16RUN git config --global user.email "korap+docker@ids-mannheim.de" && \
17 git config --global user.name "Docker"
18
19# Install Koral
Akron8ae24622023-10-13 09:44:55 +020020RUN curl -I https://github.com/KorAP/Koral/releases/latest | \
21 grep location | \
22 perl -e '$|++; <> =~ m/tag\/(v[\d\.]+(?:-release)?)/; print "https://github.com/KorAP/Koral/archive/refs/tags/${1}\.zip\n"' |\
23 wget -i - && \
24 unzip *.zip && \
25 cd Koral-* && \
Akron26ddf722020-08-11 15:39:32 +020026 mvn clean install
27
Akron8ae24622023-10-13 09:44:55 +020028RUN rm -r Koral-* v*.zip
29
30RUN mkdir built
Akron26ddf722020-08-11 15:39:32 +020031
32# Install Krill
Akron8ae24622023-10-13 09:44:55 +020033RUN curl -I https://github.com/KorAP/Krill/releases/latest | \
34 grep location | \
35 perl -e '$|++; <> =~ m/tag\/(v[\d\.]+(?:-release)?)/; print "https://github.com/KorAP/Krill/archive/refs/tags/${1}\.zip\n"' |\
36 wget -i - && \
37 unzip *.zip && \
38 cd Krill-* && \
Akron200aec42022-03-29 12:36:36 +020039 mvn clean install && \
40 mvn -Dmaven.test.skip=true package && \
41 mv target/Krill-Indexer.jar /kustvakt/built/Krill-Indexer.jar
Akron26ddf722020-08-11 15:39:32 +020042
Akron8ae24622023-10-13 09:44:55 +020043RUN rm -r Krill-* v*.zip
Akron26ddf722020-08-11 15:39:32 +020044
Akron26ddf722020-08-11 15:39:32 +020045# Package lite
Akrond0ca9902023-05-17 08:57:07 +020046RUN cd full && \
47 mvn clean package -P lite && \
Akron26ddf722020-08-11 15:39:32 +020048 find target/Kustvakt-lite-*.jar -exec mv {} ../built/Kustvakt-lite.jar ';'
49
Akrond0ca9902023-05-17 08:57:07 +020050RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' full/src/main/resources/kustvakt-lite.conf \
Akron26ddf722020-08-11 15:39:32 +020051 > built/kustvakt-lite.conf
52
Akrona2228232022-05-23 17:25:48 +020053# Package full
54RUN cd full && \
Akrond0ca9902023-05-17 08:57:07 +020055 mvn clean package -DskipTests=true && \
Akrona2228232022-05-23 17:25:48 +020056 find target/Kustvakt-full-*.jar -exec mv {} ../built/Kustvakt-full.jar ';'
57
58RUN cat full/src/main/resources/kustvakt.conf | \
59 sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' | \
60 sed 's!\(ldap\.config\s*=\).\+!\1\/kustvakt\/ldap\/ldap\.conf!' | \
61 sed 's!\(oauth2\.initial\.super\.client\s*=\).\+!\1\/true!' | \
62 sed '$ a oauth2.initial.super.client = true' \
63 > built/kustvakt.conf
64
65RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \
66 full/src/main/resources/embedded-ldap-example.conf \
67 > built/ldap.conf
68
69RUN cat full/src/main/resources/example-users.ldif \
70 > built/ldap.ldif
71
Akron26ddf722020-08-11 15:39:32 +020072RUN apk del git \
Akron8ae24622023-10-13 09:44:55 +020073 perl \
74 curl \
75 wget \
Akron26ddf722020-08-11 15:39:32 +020076 maven
77
78RUN cd ${M2_HOME} && rm -r .m2
79
Akrone848ec02023-10-24 15:22:49 +020080# Cleanup
81RUN rm -r full && \
82 rm -r wiki-index
83
84FROM busybox:latest AS example-index
85
86WORKDIR /kustvakt
87
88RUN addgroup -S korap && \
89 adduser -S kustvakt -G korap && \
90 mkdir kustvakt && \
91 chown -R kustvakt.korap /kustvakt
92
93COPY --from=builder /kustvakt/sample-index /kustvakt/index
94
95USER kustvakt
96
97CMD ["sh"]
98
Akrona2228232022-05-23 17:25:48 +020099FROM openjdk:19-alpine AS kustvakt-lite
Akron26ddf722020-08-11 15:39:32 +0200100
101RUN addgroup -S korap && \
102 adduser -S kustvakt -G korap && \
103 mkdir kustvakt && \
104 chown -R kustvakt.korap /kustvakt
105
106WORKDIR /kustvakt
107
Akronf9c12d12022-12-05 14:24:08 +0100108COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/
109COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/
110COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akron26ddf722020-08-11 15:39:32 +0200111
112USER kustvakt
113
114EXPOSE 8089
115
Akron200aec42022-03-29 12:36:36 +0200116ENTRYPOINT [ "java", "-jar" ]
117
118CMD [ "Kustvakt-lite.jar" ]
Akron26ddf722020-08-11 15:39:32 +0200119
Akrona2228232022-05-23 17:25:48 +0200120FROM openjdk:19-alpine AS kustvakt-full
121
122RUN addgroup -S korap && \
123 adduser -S kustvakt -G korap && \
124 mkdir kustvakt && \
125 chown -R kustvakt.korap /kustvakt
126
127WORKDIR /kustvakt
128
129RUN mkdir ./ldap \
130 mkdir ./client
131
132COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/
133COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/
134COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/
Akronf9c12d12022-12-05 14:24:08 +0100135COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akrona2228232022-05-23 17:25:48 +0200136
137USER kustvakt
138
139EXPOSE 8089
140
141ENTRYPOINT [ "java", "-jar" ]
142
143CMD [ "Kustvakt-full.jar" ]
144
145# docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full .
146# docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite .
Akrone848ec02023-10-24 15:22:49 +0200147# docker build -f Dockerfile -t korap/example-index:{nr} --target example-index .