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