Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 1 | # Build assets in builder image |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [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 | |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [diff] [blame] | 28 | # Use alpine linux AS base image |
| 29 | FROM alpine:latest AS kalamar |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 30 | |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 31 | RUN apk update && \ |
| 32 | apk add --no-cache git \ |
| 33 | perl \ |
| 34 | perl-io-socket-ssl \ |
| 35 | perl-dev \ |
| 36 | g++ \ |
| 37 | make \ |
| 38 | wget \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 39 | perl-doc \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 40 | libxml2-dev \ |
Marc Kupietz | 03cc368 | 2024-12-16 14:20:54 +0100 | [diff] [blame^] | 41 | perl-xml-libxml \ |
| 42 | perl-module-pluggable \ |
| 43 | perl-datetime \ |
| 44 | perl-readonly \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 45 | unzip \ |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [diff] [blame] | 46 | curl && \ |
| 47 | set -o pipefail |
| 48 | |
| 49 | RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm |
| 50 | |
| 51 | RUN cpm install --test -g Cpanel::JSON::XS File::ShareDir::Install EV IO::Socket::Socks && \ |
| 52 | cpm install --test -g "https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.22.tar.gz" && \ |
| 53 | cpm install --test -g "https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.5.0.tar.gz" && \ |
| 54 | cpm install --test -g "https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.55.tar.gz" && \ |
| 55 | cpm install --test -g "https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.3.tar.gz" |
Akron | 1b9c243 | 2024-09-03 09:27:18 +0200 | [diff] [blame] | 56 | |
| 57 | # Copy assets from former container |
| 58 | COPY --from=assetbuilder /kalamar /kalamar |
| 59 | |
| 60 | WORKDIR /kalamar |
| 61 | |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 62 | # Install Kalamar including all dependencies |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [diff] [blame] | 63 | RUN cpm install --test -g |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 64 | |
| 65 | # Remove all build dependencies |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [diff] [blame] | 66 | RUN rm /bin/cpm && \ |
| 67 | apk del git \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 68 | perl-dev \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 69 | perl-doc \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 70 | g++ \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 71 | wget \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 72 | libxml2-dev \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 73 | curl && \ |
| 74 | rm -rf /root/.cpanm \ |
Akron | efa2f76 | 2023-11-13 14:27:54 +0100 | [diff] [blame] | 75 | /usr/local/share/man |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 76 | |
| 77 | RUN addgroup -S korap && \ |
| 78 | adduser -S kalamar -G korap && \ |
Marc Kupietz | 03cc368 | 2024-12-16 14:20:54 +0100 | [diff] [blame^] | 79 | chown -R kalamar:korap /kalamar |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 80 | |
| 81 | USER kalamar |
| 82 | |
Akron | fce76d2 | 2022-03-28 19:42:58 +0200 | [diff] [blame] | 83 | RUN mkdir /kalamar/data |
| 84 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 85 | ENV MOJO_PORT 64543 |
| 86 | ENV MOJO_LISTEN http://*:${MOJO_PORT} |
| 87 | ENV MOJO_MODE production |
| 88 | |
Akron | 34b4c93 | 2023-03-20 16:49:34 +0100 | [diff] [blame] | 89 | RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf |
Akron | 77645c8 | 2022-02-24 18:21:27 +0100 | [diff] [blame] | 90 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 91 | EXPOSE ${MOJO_PORT} |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 92 | |
| 93 | ENTRYPOINT [ "perl", "script/kalamar" ] |
| 94 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 95 | CMD [ "daemon" ] |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 96 | |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 97 | LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion" |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 98 | LABEL maintainer="korap@ids-mannheim.de" |
| 99 | LABEL repository="https://github.com/KorAP/Kalamar" |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 100 | |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 101 | # docker build -f Dockerfile -t korap/kalamar:x.xx-large --target kalamar . |
Akron | efa2f76 | 2023-11-13 14:27:54 +0100 | [diff] [blame] | 102 | |
| 103 | # Slimming (https://github.com/slimtoolkit/slim): |
| 104 | # slim build --http-probe=true \ |
Akron | d77eefe | 2024-08-26 14:01:09 +0200 | [diff] [blame] | 105 | # --exec="perl Makefile.PL && make test && unzip -v" \ |
Akron | efa2f76 | 2023-11-13 14:27:54 +0100 | [diff] [blame] | 106 | # --include-workdir=true \ |
Akron | d77eefe | 2024-08-26 14:01:09 +0200 | [diff] [blame] | 107 | # --include-path="/usr/local/share/perl5/site_perl/KorAP/" \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 108 | # --tag korap/kalamar:x.xx \ |
| 109 | # --tag korap/kalamar:latest \ |
| 110 | # korap/kalamar:x.xx-large |