Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 1 | # Use alpine linux as base image |
Marc Kupietz | af06c46 | 2022-11-17 17:25:35 +0100 | [diff] [blame] | 2 | FROM openjdk:19-alpine as builder |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 3 | |
| 4 | # Copy repository respecting .dockerignore |
| 5 | COPY . /kustvakt |
| 6 | |
| 7 | WORKDIR /kustvakt |
| 8 | |
| 9 | RUN apk update && \ |
| 10 | apk add --no-cache git \ |
| 11 | maven |
| 12 | |
| 13 | RUN git config --global user.email "korap+docker@ids-mannheim.de" && \ |
| 14 | git config --global user.name "Docker" |
| 15 | |
| 16 | # Install Koral |
| 17 | RUN mkdir Koral && git clone https://github.com/KorAP/Koral.git Koral && \ |
| 18 | cd Koral && \ |
| 19 | git checkout master && \ |
| 20 | mvn clean install |
| 21 | |
| 22 | RUN rm -r Koral |
| 23 | |
| 24 | # Install Krill |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 25 | RUN mkdir built && \ |
| 26 | git clone https://github.com/KorAP/Krill.git Krill && \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 27 | cd Krill && \ |
| 28 | git checkout master && \ |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 29 | mvn clean install && \ |
| 30 | mvn -Dmaven.test.skip=true package && \ |
| 31 | mv target/Krill-Indexer.jar /kustvakt/built/Krill-Indexer.jar |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 32 | |
| 33 | RUN rm -r Krill |
| 34 | |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 35 | # Package lite |
Akron | d0ca990 | 2023-05-17 08:57:07 +0200 | [diff] [blame^] | 36 | RUN cd full && \ |
| 37 | mvn clean package -P lite && \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 38 | find target/Kustvakt-lite-*.jar -exec mv {} ../built/Kustvakt-lite.jar ';' |
| 39 | |
Akron | d0ca990 | 2023-05-17 08:57:07 +0200 | [diff] [blame^] | 40 | RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' full/src/main/resources/kustvakt-lite.conf \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 41 | > built/kustvakt-lite.conf |
| 42 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 43 | # Package full |
| 44 | RUN cd full && \ |
Akron | d0ca990 | 2023-05-17 08:57:07 +0200 | [diff] [blame^] | 45 | mvn clean package -DskipTests=true && \ |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 46 | find target/Kustvakt-full-*.jar -exec mv {} ../built/Kustvakt-full.jar ';' |
| 47 | |
| 48 | RUN 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 | |
| 55 | RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \ |
| 56 | full/src/main/resources/embedded-ldap-example.conf \ |
| 57 | > built/ldap.conf |
| 58 | |
| 59 | RUN cat full/src/main/resources/example-users.ldif \ |
| 60 | > built/ldap.ldif |
| 61 | |
| 62 | # Cleanup |
Akron | d0ca990 | 2023-05-17 08:57:07 +0200 | [diff] [blame^] | 63 | RUN rm -r full && \ |
| 64 | rm -r sample-index && \ |
| 65 | rm -r wiki-index |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 66 | |
| 67 | RUN apk del git \ |
| 68 | maven |
| 69 | |
| 70 | RUN cd ${M2_HOME} && rm -r .m2 |
| 71 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 72 | FROM openjdk:19-alpine AS kustvakt-lite |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 73 | |
| 74 | RUN addgroup -S korap && \ |
| 75 | adduser -S kustvakt -G korap && \ |
| 76 | mkdir kustvakt && \ |
| 77 | chown -R kustvakt.korap /kustvakt |
| 78 | |
| 79 | WORKDIR /kustvakt |
| 80 | |
Akron | f9c12d1 | 2022-12-05 14:24:08 +0100 | [diff] [blame] | 81 | COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/ |
| 82 | COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/ |
| 83 | COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 84 | |
| 85 | USER kustvakt |
| 86 | |
| 87 | EXPOSE 8089 |
| 88 | |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 89 | ENTRYPOINT [ "java", "-jar" ] |
| 90 | |
| 91 | CMD [ "Kustvakt-lite.jar" ] |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 92 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 93 | FROM openjdk:19-alpine AS kustvakt-full |
| 94 | |
| 95 | RUN addgroup -S korap && \ |
| 96 | adduser -S kustvakt -G korap && \ |
| 97 | mkdir kustvakt && \ |
| 98 | chown -R kustvakt.korap /kustvakt |
| 99 | |
| 100 | WORKDIR /kustvakt |
| 101 | |
| 102 | RUN mkdir ./ldap \ |
| 103 | mkdir ./client |
| 104 | |
| 105 | COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/ |
| 106 | COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/ |
| 107 | COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/ |
Akron | f9c12d1 | 2022-12-05 14:24:08 +0100 | [diff] [blame] | 108 | COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 109 | |
| 110 | USER kustvakt |
| 111 | |
| 112 | EXPOSE 8089 |
| 113 | |
| 114 | ENTRYPOINT [ "java", "-jar" ] |
| 115 | |
| 116 | CMD [ "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 . |