blob: ae5beb1dabf46724217623d976db1634774ab5b8 [file] [log] [blame]
Akron26ddf722020-08-11 15:39:32 +02001# Use alpine linux as base image
Akron7ba60862024-08-09 16:55:01 +02002FROM eclipse-temurin:22-jdk-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
Akron8ba7a152024-01-22 08:53:18 +010046RUN mvn clean package -P lite && \
47 find target/Kustvakt-lite-*.jar -exec mv {} /kustvakt/built/Kustvakt-lite.jar ';'
Akron26ddf722020-08-11 15:39:32 +020048
Akron8ba7a152024-01-22 08:53:18 +010049RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' src/main/resources/kustvakt-lite.conf \
Akron26ddf722020-08-11 15:39:32 +020050 > built/kustvakt-lite.conf
51
Akrona2228232022-05-23 17:25:48 +020052# Package full
Akron8ba7a152024-01-22 08:53:18 +010053RUN mvn clean package -DskipTests=true && \
54 find target/Kustvakt-full-*.jar -exec mv {} /kustvakt/built/Kustvakt-full.jar ';'
Akrona2228232022-05-23 17:25:48 +020055
Akron8ba7a152024-01-22 08:53:18 +010056RUN cat src/main/resources/kustvakt.conf | \
Akrona2228232022-05-23 17:25:48 +020057 sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' | \
58 sed 's!\(ldap\.config\s*=\).\+!\1\/kustvakt\/ldap\/ldap\.conf!' | \
59 sed 's!\(oauth2\.initial\.super\.client\s*=\).\+!\1\/true!' | \
60 sed '$ a oauth2.initial.super.client = true' \
61 > built/kustvakt.conf
62
63RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \
Akron8ba7a152024-01-22 08:53:18 +010064 src/main/resources/embedded-ldap-example.conf \
Akrona2228232022-05-23 17:25:48 +020065 > built/ldap.conf
66
Akron8ba7a152024-01-22 08:53:18 +010067RUN cat src/main/resources/example-users.ldif \
Akrona2228232022-05-23 17:25:48 +020068 > built/ldap.ldif
69
Akron26ddf722020-08-11 15:39:32 +020070RUN apk del git \
Akron8ae24622023-10-13 09:44:55 +020071 perl \
72 curl \
73 wget \
Akron26ddf722020-08-11 15:39:32 +020074 maven
75
76RUN cd ${M2_HOME} && rm -r .m2
77
Akrone848ec02023-10-24 15:22:49 +020078# Cleanup
Akron8ba7a152024-01-22 08:53:18 +010079RUN rm -r src && \
Akrone848ec02023-10-24 15:22:49 +020080 rm -r wiki-index
81
82FROM busybox:latest AS example-index
83
84WORKDIR /kustvakt
85
86RUN addgroup -S korap && \
87 adduser -S kustvakt -G korap && \
88 mkdir kustvakt && \
89 chown -R kustvakt.korap /kustvakt
90
91COPY --from=builder /kustvakt/sample-index /kustvakt/index
92
93USER kustvakt
94
95CMD ["sh"]
96
Akron7ba60862024-08-09 16:55:01 +020097FROM eclipse-temurin:22-jre-alpine AS kustvakt-lite
Akron26ddf722020-08-11 15:39:32 +020098
99RUN addgroup -S korap && \
100 adduser -S kustvakt -G korap && \
101 mkdir kustvakt && \
102 chown -R kustvakt.korap /kustvakt
103
104WORKDIR /kustvakt
105
Akronf9c12d12022-12-05 14:24:08 +0100106COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/
107COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/
108COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akron26ddf722020-08-11 15:39:32 +0200109
110USER kustvakt
111
112EXPOSE 8089
113
Akron200aec42022-03-29 12:36:36 +0200114ENTRYPOINT [ "java", "-jar" ]
115
116CMD [ "Kustvakt-lite.jar" ]
Akron26ddf722020-08-11 15:39:32 +0200117
Akron7ba60862024-08-09 16:55:01 +0200118FROM eclipse-temurin:22-jre-alpine AS kustvakt-full
Akrona2228232022-05-23 17:25:48 +0200119
120RUN addgroup -S korap && \
121 adduser -S kustvakt -G korap && \
122 mkdir kustvakt && \
123 chown -R kustvakt.korap /kustvakt
124
125WORKDIR /kustvakt
126
127RUN mkdir ./ldap \
128 mkdir ./client
129
130COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/
131COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/
132COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/
Akronf9c12d12022-12-05 14:24:08 +0100133COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
Akrona2228232022-05-23 17:25:48 +0200134
135USER kustvakt
136
137EXPOSE 8089
138
139ENTRYPOINT [ "java", "-jar" ]
140
141CMD [ "Kustvakt-full.jar" ]
142
143# docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full .
144# docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite .
Akrone848ec02023-10-24 15:22:49 +0200145# docker build -f Dockerfile -t korap/example-index:{nr} --target example-index .