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 | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 29 | FROM alpine:latest as kalamar |
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 \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 44 | perl-doc \ |
| 45 | libxml2 \ |
| 46 | libxml2-dev \ |
| 47 | unzip \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 48 | curl && \ |
| 49 | set -o pipefail && \ |
| 50 | curl -L https://cpanmin.us | perl - App::cpanminus && \ |
Akron | b9ca92b | 2024-03-14 10:20:18 +0100 | [diff] [blame] | 51 | 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] | 52 | Cpanel::JSON::XS \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 53 | File::ShareDir::Install \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 54 | EV \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 55 | IO::Socket::Socks \ |
| 56 | https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.5.0.tar.gz \ |
| 57 | https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.55.tar.gz \ |
| 58 | https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.3.tar.gz |
Akron | ab6592d | 2022-02-24 18:23:11 +0100 | [diff] [blame] | 59 | |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 60 | # Install Kalamar including all dependencies |
| 61 | RUN cpanm --installdeps . -M https://cpan.metacpan.org |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 62 | |
| 63 | # Remove all build dependencies |
| 64 | RUN apk del git \ |
| 65 | perl-dev \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 66 | perl-doc \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 67 | g++ \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 68 | wget \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 69 | libxml2-dev \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 70 | curl && \ |
| 71 | rm -rf /root/.cpanm \ |
Akron | efa2f76 | 2023-11-13 14:27:54 +0100 | [diff] [blame] | 72 | /usr/local/share/man |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 73 | |
| 74 | RUN addgroup -S korap && \ |
| 75 | adduser -S kalamar -G korap && \ |
| 76 | chown -R kalamar.korap /kalamar |
| 77 | |
| 78 | USER kalamar |
| 79 | |
Akron | fce76d2 | 2022-03-28 19:42:58 +0200 | [diff] [blame] | 80 | RUN mkdir /kalamar/data |
| 81 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 82 | ENV MOJO_PORT 64543 |
| 83 | ENV MOJO_LISTEN http://*:${MOJO_PORT} |
| 84 | ENV MOJO_MODE production |
| 85 | |
Akron | 34b4c93 | 2023-03-20 16:49:34 +0100 | [diff] [blame] | 86 | RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf |
Akron | 77645c8 | 2022-02-24 18:21:27 +0100 | [diff] [blame] | 87 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 88 | EXPOSE ${MOJO_PORT} |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 89 | |
| 90 | ENTRYPOINT [ "perl", "script/kalamar" ] |
| 91 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 92 | CMD [ "daemon" ] |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 93 | |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 94 | LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion" |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 95 | LABEL maintainer="korap@ids-mannheim.de" |
| 96 | LABEL repository="https://github.com/KorAP/Kalamar" |
Akron | efd471e | 2022-03-29 15:07:17 +0200 | [diff] [blame] | 97 | |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 98 | # docker build -f Dockerfile -t korap/kalamar:x.xx-large --target kalamar . |
Akron | efa2f76 | 2023-11-13 14:27:54 +0100 | [diff] [blame] | 99 | |
| 100 | # Slimming (https://github.com/slimtoolkit/slim): |
| 101 | # slim build --http-probe=true \ |
Akron | d77eefe | 2024-08-26 14:01:09 +0200 | [diff] [blame^] | 102 | # --exec="perl Makefile.PL && make test && unzip -v" \ |
Akron | efa2f76 | 2023-11-13 14:27:54 +0100 | [diff] [blame] | 103 | # --include-workdir=true \ |
Akron | d77eefe | 2024-08-26 14:01:09 +0200 | [diff] [blame^] | 104 | # --include-path="/usr/local/share/perl5/site_perl/KorAP/" \ |
Akron | b92fbb6 | 2024-08-09 15:58:47 +0200 | [diff] [blame] | 105 | # --tag korap/kalamar:x.xx \ |
| 106 | # --tag korap/kalamar:latest \ |
| 107 | # korap/kalamar:x.xx-large |