| # Use alpine linux as base image |
| FROM openjdk:19-alpine as builder |
| |
| # Copy repository respecting .dockerignore |
| COPY . /kustvakt |
| |
| WORKDIR /kustvakt |
| |
| RUN apk update && \ |
| apk add --no-cache git \ |
| maven |
| |
| RUN git config --global user.email "korap+docker@ids-mannheim.de" && \ |
| git config --global user.name "Docker" |
| |
| # Install Koral |
| RUN mkdir Koral && git clone https://github.com/KorAP/Koral.git Koral && \ |
| cd Koral && \ |
| git checkout master && \ |
| mvn clean install |
| |
| RUN rm -r Koral |
| |
| # Install Krill |
| RUN mkdir built && \ |
| git clone https://github.com/KorAP/Krill.git Krill && \ |
| cd Krill && \ |
| git checkout master && \ |
| mvn clean install && \ |
| mvn -Dmaven.test.skip=true package && \ |
| mv target/Krill-Indexer.jar /kustvakt/built/Krill-Indexer.jar |
| |
| RUN rm -r Krill |
| |
| # Package lite |
| RUN cd full && \ |
| mvn clean package -P lite && \ |
| find target/Kustvakt-lite-*.jar -exec mv {} ../built/Kustvakt-lite.jar ';' |
| |
| RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' full/src/main/resources/kustvakt-lite.conf \ |
| > built/kustvakt-lite.conf |
| |
| # Package full |
| RUN cd full && \ |
| mvn clean package -DskipTests=true && \ |
| find target/Kustvakt-full-*.jar -exec mv {} ../built/Kustvakt-full.jar ';' |
| |
| RUN cat full/src/main/resources/kustvakt.conf | \ |
| sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' | \ |
| sed 's!\(ldap\.config\s*=\).\+!\1\/kustvakt\/ldap\/ldap\.conf!' | \ |
| sed 's!\(oauth2\.initial\.super\.client\s*=\).\+!\1\/true!' | \ |
| sed '$ a oauth2.initial.super.client = true' \ |
| > built/kustvakt.conf |
| |
| RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \ |
| full/src/main/resources/embedded-ldap-example.conf \ |
| > built/ldap.conf |
| |
| RUN cat full/src/main/resources/example-users.ldif \ |
| > built/ldap.ldif |
| |
| RUN apk del git \ |
| maven |
| |
| RUN cd ${M2_HOME} && rm -r .m2 |
| |
| # Cleanup |
| RUN rm -r full && \ |
| rm -r wiki-index |
| |
| FROM busybox:latest AS example-index |
| |
| WORKDIR /kustvakt |
| |
| RUN addgroup -S korap && \ |
| adduser -S kustvakt -G korap && \ |
| mkdir kustvakt && \ |
| chown -R kustvakt.korap /kustvakt |
| |
| COPY --from=builder /kustvakt/sample-index /kustvakt/index |
| |
| USER kustvakt |
| |
| CMD ["sh"] |
| |
| FROM openjdk:19-alpine AS kustvakt-lite |
| |
| RUN addgroup -S korap && \ |
| adduser -S kustvakt -G korap && \ |
| mkdir kustvakt && \ |
| chown -R kustvakt.korap /kustvakt |
| |
| WORKDIR /kustvakt |
| |
| COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/ |
| COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/ |
| COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
| |
| USER kustvakt |
| |
| EXPOSE 8089 |
| |
| ENTRYPOINT [ "java", "-jar" ] |
| |
| CMD [ "Kustvakt-lite.jar" ] |
| |
| FROM openjdk:19-alpine AS kustvakt-full |
| |
| RUN addgroup -S korap && \ |
| adduser -S kustvakt -G korap && \ |
| mkdir kustvakt && \ |
| chown -R kustvakt.korap /kustvakt |
| |
| WORKDIR /kustvakt |
| |
| RUN mkdir ./ldap \ |
| mkdir ./client |
| |
| COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/ |
| COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/ |
| COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/ |
| COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/ |
| |
| USER kustvakt |
| |
| EXPOSE 8089 |
| |
| ENTRYPOINT [ "java", "-jar" ] |
| |
| CMD [ "Kustvakt-full.jar" ] |
| |
| # docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full . |
| # docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite . |
| # docker build -f Dockerfile -t korap/example-index:{nr} --target example-index . |