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 | |
| 35 | # Install Kustvakt core |
Marc Kupietz | af06c46 | 2022-11-17 17:25:35 +0100 | [diff] [blame] | 36 | RUN mvn -f core/pom.xml clean install |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 37 | |
| 38 | # Package lite |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 39 | RUN cd lite && \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 40 | mvn clean package && \ |
| 41 | find target/Kustvakt-lite-*.jar -exec mv {} ../built/Kustvakt-lite.jar ';' |
| 42 | |
| 43 | RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' lite/src/main/resources/kustvakt-lite.conf \ |
| 44 | > built/kustvakt-lite.conf |
| 45 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 46 | # Package full |
| 47 | RUN cd full && \ |
| 48 | mvn clean package && \ |
| 49 | find target/Kustvakt-full-*.jar -exec mv {} ../built/Kustvakt-full.jar ';' |
| 50 | |
| 51 | RUN 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 | |
| 58 | RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \ |
| 59 | full/src/main/resources/embedded-ldap-example.conf \ |
| 60 | > built/ldap.conf |
| 61 | |
| 62 | RUN cat full/src/main/resources/example-users.ldif \ |
| 63 | > built/ldap.ldif |
| 64 | |
| 65 | # Cleanup |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 66 | RUN rm -r core && \ |
| 67 | rm -r full && \ |
| 68 | rm -r lite && \ |
| 69 | rm -r sample-index |
| 70 | |
| 71 | RUN apk del git \ |
| 72 | maven |
| 73 | |
| 74 | RUN cd ${M2_HOME} && rm -r .m2 |
| 75 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 76 | FROM openjdk:19-alpine AS kustvakt-lite |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 77 | |
| 78 | RUN addgroup -S korap && \ |
| 79 | adduser -S kustvakt -G korap && \ |
| 80 | mkdir kustvakt && \ |
| 81 | chown -R kustvakt.korap /kustvakt |
| 82 | |
| 83 | WORKDIR /kustvakt |
| 84 | |
Akron | f9c12d1 | 2022-12-05 14:24:08 +0100 | [diff] [blame^] | 85 | COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/ |
| 86 | COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/ |
| 87 | COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 88 | |
| 89 | USER kustvakt |
| 90 | |
| 91 | EXPOSE 8089 |
| 92 | |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 93 | ENTRYPOINT [ "java", "-jar" ] |
| 94 | |
| 95 | CMD [ "Kustvakt-lite.jar" ] |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 96 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 97 | |
| 98 | FROM openjdk:19-alpine AS kustvakt-full |
| 99 | |
| 100 | RUN addgroup -S korap && \ |
| 101 | adduser -S kustvakt -G korap && \ |
| 102 | mkdir kustvakt && \ |
| 103 | chown -R kustvakt.korap /kustvakt |
| 104 | |
| 105 | WORKDIR /kustvakt |
| 106 | |
| 107 | RUN mkdir ./ldap \ |
| 108 | mkdir ./client |
| 109 | |
| 110 | COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/ |
| 111 | COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/ |
| 112 | COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/ |
Akron | f9c12d1 | 2022-12-05 14:24:08 +0100 | [diff] [blame^] | 113 | COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 114 | |
| 115 | USER kustvakt |
| 116 | |
| 117 | EXPOSE 8089 |
| 118 | |
| 119 | ENTRYPOINT [ "java", "-jar" ] |
| 120 | |
| 121 | CMD [ "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 . |