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