Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 1 | # Build assets in builder image |
dependabot[bot] | cf833f3 | 2022-12-22 14:47:50 +0000 | [diff] [blame] | 2 | FROM node:19 as assetbuilder |
| 3 | |
| 4 | WORKDIR '/app' |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 5 | |
| 6 | # This follows the "multi-stage build" pattern |
| 7 | |
Akron | 7ca7387 | 2021-03-08 11:29:11 +0100 | [diff] [blame] | 8 | RUN npm install grunt && \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 9 | npm install -g grunt-cli |
| 10 | |
| 11 | # Copy repository respecting .dockerignore |
| 12 | COPY . /kalamar |
| 13 | |
| 14 | RUN cd /kalamar && \ |
| 15 | npm install && \ |
| 16 | grunt && \ |
| 17 | rm -rf node_modules \ |
| 18 | dev/css \ |
| 19 | dev/demo \ |
| 20 | dev/font \ |
| 21 | dev/img \ |
Akron | 64b957d | 2020-10-07 22:39:53 +0200 | [diff] [blame] | 22 | dev/js/bench \ |
| 23 | dev/js/runner \ |
| 24 | dev/js/spec \ |
| 25 | dev/scss && \ |
| 26 | rm package-lock.json \ |
| 27 | dev/robots.txt |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 28 | |
| 29 | # Use alpine linux as base image |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 30 | FROM alpine:latest as kalamar-base |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 31 | |
| 32 | # Copy assets from former container |
| 33 | COPY --from=assetbuilder /kalamar /kalamar |
| 34 | |
| 35 | WORKDIR /kalamar |
| 36 | |
| 37 | RUN apk update && \ |
| 38 | apk add --no-cache git \ |
| 39 | perl \ |
| 40 | perl-io-socket-ssl \ |
| 41 | perl-dev \ |
| 42 | g++ \ |
| 43 | make \ |
| 44 | wget \ |
| 45 | curl && \ |
| 46 | set -o pipefail && \ |
| 47 | curl -L https://cpanmin.us | perl - App::cpanminus && \ |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 48 | cpanm https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.21.tar.gz \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 49 | Cpanel::JSON::XS \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 50 | EV \ |
Akron | ab6592d | 2022-02-24 18:23:11 +0100 | [diff] [blame] | 51 | IO::Socket::Socks |
| 52 | |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 53 | # Install Kalamar including all dependencies |
| 54 | RUN cpanm --installdeps . -M https://cpan.metacpan.org |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 55 | |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 56 | LABEL maintainer="korap@ids-mannheim.de" |
| 57 | LABEL repository="https://github.com/KorAP/Kalamar" |
| 58 | |
| 59 | FROM kalamar-base AS kalamar |
| 60 | |
| 61 | # Remove all build dependencies |
| 62 | RUN apk del git \ |
| 63 | perl-dev \ |
| 64 | g++ \ |
| 65 | make \ |
| 66 | wget \ |
| 67 | curl && \ |
| 68 | rm -rf /root/.cpanm \ |
| 69 | /usr/local/share/man && \ |
| 70 | rm -rf t |
| 71 | |
| 72 | RUN addgroup -S korap && \ |
| 73 | adduser -S kalamar -G korap && \ |
| 74 | chown -R kalamar.korap /kalamar |
| 75 | |
| 76 | USER kalamar |
| 77 | |
| 78 | ENV MOJO_PORT 64543 |
| 79 | ENV MOJO_LISTEN http://*:${MOJO_PORT} |
| 80 | ENV MOJO_MODE production |
| 81 | |
| 82 | EXPOSE ${MOJO_PORT} |
| 83 | |
| 84 | ENTRYPOINT [ "perl", "script/kalamar" ] |
| 85 | |
| 86 | CMD [ "daemon" ] |
| 87 | |
| 88 | LABEL description="Docker Image for Kalamar, the KorAP user frontend" |
| 89 | |
| 90 | |
| 91 | FROM kalamar-base AS kalamar-convert |
| 92 | |
| 93 | RUN apk update && \ |
| 94 | apk add --no-cache \ |
| 95 | perl-doc \ |
| 96 | libxml2-dev \ |
| 97 | libxml2 \ |
| 98 | unzip && \ |
| 99 | set -o pipefail && \ |
| 100 | cpanm File::ShareDir::Install |
| 101 | |
| 102 | RUN cpanm \ |
Akron | a85abb4 | 2023-02-07 14:30:33 +0100 | [diff] [blame] | 103 | https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.4.1.tar.gz \ |
Marc Kupietz | 346b67d | 2023-02-14 15:20:26 +0100 | [diff] [blame] | 104 | https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.49.tar.gz \ |
Akron | df92c83 | 2023-03-29 11:05:37 +0200 | [diff] [blame^] | 105 | https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.1.tar.gz |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 106 | |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 107 | # Remove all build dependencies |
| 108 | RUN apk del git \ |
| 109 | perl-dev \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 110 | perl-doc \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 111 | g++ \ |
| 112 | make \ |
| 113 | wget \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 114 | libxml2-dev \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 115 | curl && \ |
| 116 | rm -rf /root/.cpanm \ |
Akron | 64b957d | 2020-10-07 22:39:53 +0200 | [diff] [blame] | 117 | /usr/local/share/man && \ |
| 118 | rm -rf t |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 119 | |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 120 | |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 121 | RUN addgroup -S korap && \ |
| 122 | adduser -S kalamar -G korap && \ |
| 123 | chown -R kalamar.korap /kalamar |
| 124 | |
| 125 | USER kalamar |
| 126 | |
Akron | fce76d2 | 2022-03-28 19:42:58 +0200 | [diff] [blame] | 127 | RUN mkdir /kalamar/data |
| 128 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 129 | ENV MOJO_PORT 64543 |
| 130 | ENV MOJO_LISTEN http://*:${MOJO_PORT} |
| 131 | ENV MOJO_MODE production |
| 132 | |
Akron | 34b4c93 | 2023-03-20 16:49:34 +0100 | [diff] [blame] | 133 | RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf |
Akron | 77645c8 | 2022-02-24 18:21:27 +0100 | [diff] [blame] | 134 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 135 | EXPOSE ${MOJO_PORT} |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 136 | |
| 137 | ENTRYPOINT [ "perl", "script/kalamar" ] |
| 138 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 139 | CMD [ "daemon" ] |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 140 | |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 141 | LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion" |
| 142 | |
Akron | e4276a9 | 2022-11-30 14:07:15 +0100 | [diff] [blame] | 143 | # docker build -f Dockerfile -t korap/kalamar:x.xx-conv --target kalamar-convert . |
| 144 | # docker build -f Dockerfile -t korap/kalamar:x.xx --target kalamar . |