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 | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 85 | COPY --from=builder /kustvakt/built/Kustvakt-lite.* /kustvakt/ |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 86 | |
| 87 | USER kustvakt |
| 88 | |
| 89 | EXPOSE 8089 |
| 90 | |
Akron | 200aec4 | 2022-03-29 12:36:36 +0200 | [diff] [blame] | 91 | ENTRYPOINT [ "java", "-jar" ] |
| 92 | |
| 93 | CMD [ "Kustvakt-lite.jar" ] |
Akron | 26ddf72 | 2020-08-11 15:39:32 +0200 | [diff] [blame] | 94 | |
Akron | a222823 | 2022-05-23 17:25:48 +0200 | [diff] [blame] | 95 | |
| 96 | FROM openjdk:19-alpine AS kustvakt-full |
| 97 | |
| 98 | RUN addgroup -S korap && \ |
| 99 | adduser -S kustvakt -G korap && \ |
| 100 | mkdir kustvakt && \ |
| 101 | chown -R kustvakt.korap /kustvakt |
| 102 | |
| 103 | WORKDIR /kustvakt |
| 104 | |
| 105 | RUN mkdir ./ldap \ |
| 106 | mkdir ./client |
| 107 | |
| 108 | COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/ |
| 109 | COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/ |
| 110 | COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/ |
| 111 | |
| 112 | USER kustvakt |
| 113 | |
| 114 | EXPOSE 8089 |
| 115 | |
| 116 | ENTRYPOINT [ "java", "-jar" ] |
| 117 | |
| 118 | CMD [ "Kustvakt-full.jar" ] |
| 119 | |
| 120 | # docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full . |
| 121 | # docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite . |