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