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 | 1b71b4d | 2022-04-12 14:17:30 +0200 | [diff] [blame] | 103 | https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.3.3.tar.gz \ |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 104 | https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.45.tar.gz |
| 105 | |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 106 | # Remove all build dependencies |
| 107 | RUN apk del git \ |
| 108 | perl-dev \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 109 | perl-doc \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 110 | g++ \ |
| 111 | make \ |
| 112 | wget \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 113 | libxml2-dev \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 114 | curl && \ |
| 115 | rm -rf /root/.cpanm \ |
Akron | 64b957d | 2020-10-07 22:39:53 +0200 | [diff] [blame] | 116 | /usr/local/share/man && \ |
| 117 | rm -rf t |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 118 | |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 119 | |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 120 | RUN addgroup -S korap && \ |
| 121 | adduser -S kalamar -G korap && \ |
| 122 | chown -R kalamar.korap /kalamar |
| 123 | |
| 124 | USER kalamar |
| 125 | |
Akron | fce76d2 | 2022-03-28 19:42:58 +0200 | [diff] [blame] | 126 | RUN mkdir /kalamar/data |
| 127 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 128 | ENV MOJO_PORT 64543 |
| 129 | ENV MOJO_LISTEN http://*:${MOJO_PORT} |
| 130 | ENV MOJO_MODE production |
| 131 | |
Akron | 77645c8 | 2022-02-24 18:21:27 +0100 | [diff] [blame] | 132 | RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML']}}" > kalamar.production.conf |
| 133 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 134 | EXPOSE ${MOJO_PORT} |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 135 | |
| 136 | ENTRYPOINT [ "perl", "script/kalamar" ] |
| 137 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 138 | CMD [ "daemon" ] |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 139 | |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 140 | LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion" |
| 141 | |
Akron | e4276a9 | 2022-11-30 14:07:15 +0100 | [diff] [blame] | 142 | # docker build -f Dockerfile -t korap/kalamar:x.xx-conv --target kalamar-convert . |
| 143 | # docker build -f Dockerfile -t korap/kalamar:x.xx --target kalamar . |