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 \ |
Akron | 8ae2462 | 2023-10-13 09:44:55 +0200 | [diff] [blame^] | 11 | curl \ |
| 12 | perl \ |
| 13 | wget \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 14 | maven |
| 15 | |
| 16 | RUN git config --global user.email "korap+docker@ids-mannheim.de" && \ |
| 17 | git config --global user.name "Docker" |
| 18 | |
| 19 | # Install Koral |
Akron | 8ae2462 | 2023-10-13 09:44:55 +0200 | [diff] [blame^] | 20 | RUN 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-* && \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 26 | mvn clean install |
| 27 | |
Akron | 8ae2462 | 2023-10-13 09:44:55 +0200 | [diff] [blame^] | 28 | RUN rm -r Koral-* v*.zip |
| 29 | |
| 30 | RUN mkdir built |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 31 | |
| 32 | # Install Krill |
Akron | 8ae2462 | 2023-10-13 09:44:55 +0200 | [diff] [blame^] | 33 | RUN 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-* && \ |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 39 | mvn clean install && \ |
| 40 | mvn -Dmaven.test.skip=true package && \ |
| 41 | mv target/Krill-Indexer.jar /kustvakt/built/Krill-Indexer.jar |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 42 | |
Akron | 8ae2462 | 2023-10-13 09:44:55 +0200 | [diff] [blame^] | 43 | RUN rm -r Krill-* v*.zip |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 44 | |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 45 | # Package lite |
Akron | d0ca990 | 2023-05-17 08:57:07 +0200 | [diff] [blame] | 46 | RUN cd full && \ |
| 47 | mvn clean package -P lite && \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 48 | find target/Kustvakt-lite-*.jar -exec mv {} ../built/Kustvakt-lite.jar ';' |
| 49 | |
Akron | d0ca990 | 2023-05-17 08:57:07 +0200 | [diff] [blame] | 50 | 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] | 51 | > built/kustvakt-lite.conf |
| 52 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 53 | # Package full |
| 54 | RUN cd full && \ |
Akron | d0ca990 | 2023-05-17 08:57:07 +0200 | [diff] [blame] | 55 | mvn clean package -DskipTests=true && \ |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 56 | find target/Kustvakt-full-*.jar -exec mv {} ../built/Kustvakt-full.jar ';' |
| 57 | |
| 58 | RUN 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 | |
| 65 | RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \ |
| 66 | full/src/main/resources/embedded-ldap-example.conf \ |
| 67 | > built/ldap.conf |
| 68 | |
| 69 | RUN cat full/src/main/resources/example-users.ldif \ |
| 70 | > built/ldap.ldif |
| 71 | |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 72 | RUN apk del git \ |
Akron | 8ae2462 | 2023-10-13 09:44:55 +0200 | [diff] [blame^] | 73 | perl \ |
| 74 | curl \ |
| 75 | wget \ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 76 | maven |
| 77 | |
| 78 | RUN cd ${M2_HOME} && rm -r .m2 |
| 79 | |
Akron | e848ec0 | 2023-10-24 15:22:49 +0200 | [diff] [blame] | 80 | # Cleanup |
| 81 | RUN rm -r full && \ |
| 82 | rm -r wiki-index |
| 83 | |
| 84 | FROM busybox:latest AS example-index |
| 85 | |
| 86 | WORKDIR /kustvakt |
| 87 | |
| 88 | RUN addgroup -S korap && \ |
| 89 | adduser -S kustvakt -G korap && \ |
| 90 | mkdir kustvakt && \ |
| 91 | chown -R kustvakt.korap /kustvakt |
| 92 | |
| 93 | COPY --from=builder /kustvakt/sample-index /kustvakt/index |
| 94 | |
| 95 | USER kustvakt |
| 96 | |
| 97 | CMD ["sh"] |
| 98 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 99 | FROM openjdk:19-alpine AS kustvakt-lite |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 100 | |
| 101 | RUN addgroup -S korap && \ |
| 102 | adduser -S kustvakt -G korap && \ |
| 103 | mkdir kustvakt && \ |
| 104 | chown -R kustvakt.korap /kustvakt |
| 105 | |
| 106 | WORKDIR /kustvakt |
| 107 | |
Akron | f9c12d1 | 2022-12-05 14:24:08 +0100 | [diff] [blame] | 108 | COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/ |
| 109 | COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/ |
| 110 | COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 111 | |
| 112 | USER kustvakt |
| 113 | |
| 114 | EXPOSE 8089 |
| 115 | |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 116 | ENTRYPOINT [ "java", "-jar" ] |
| 117 | |
| 118 | CMD [ "Kustvakt-lite.jar" ] |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 119 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 120 | FROM openjdk:19-alpine AS kustvakt-full |
| 121 | |
| 122 | RUN addgroup -S korap && \ |
| 123 | adduser -S kustvakt -G korap && \ |
| 124 | mkdir kustvakt && \ |
| 125 | chown -R kustvakt.korap /kustvakt |
| 126 | |
| 127 | WORKDIR /kustvakt |
| 128 | |
| 129 | RUN mkdir ./ldap \ |
| 130 | mkdir ./client |
| 131 | |
| 132 | COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/ |
| 133 | COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/ |
| 134 | COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/ |
Akron | f9c12d1 | 2022-12-05 14:24:08 +0100 | [diff] [blame] | 135 | COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 136 | |
| 137 | USER kustvakt |
| 138 | |
| 139 | EXPOSE 8089 |
| 140 | |
| 141 | ENTRYPOINT [ "java", "-jar" ] |
| 142 | |
| 143 | CMD [ "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 . |
Akron | e848ec0 | 2023-10-24 15:22:49 +0200 | [diff] [blame] | 147 | # docker build -f Dockerfile -t korap/example-index:{nr} --target example-index . |