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 \ |
| 40 | libxml2 \ |
| 41 | libxml2-dev \ |
| 42 | unzip \ |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [diff] [blame^] | 43 | curl && \ |
| 44 | set -o pipefail |
| 45 | |
| 46 | RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm |
| 47 | |
| 48 | RUN cpm install --test -g Cpanel::JSON::XS File::ShareDir::Install EV IO::Socket::Socks && \ |
| 49 | cpm install --test -g "https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.22.tar.gz" && \ |
| 50 | cpm install --test -g "https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.5.0.tar.gz" && \ |
| 51 | cpm install --test -g "https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.55.tar.gz" && \ |
| 52 | 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] | 53 | |
| 54 | # Copy assets from former container |
| 55 | COPY --from=assetbuilder /kalamar /kalamar |
| 56 | |
| 57 | WORKDIR /kalamar |
| 58 | |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 59 | # Install Kalamar including all dependencies |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [diff] [blame^] | 60 | RUN cpm install --test -g |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 61 | |
| 62 | # Remove all build dependencies |
Akron | 1689140 | 2024-09-09 19:18:28 +0200 | [diff] [blame^] | 63 | RUN rm /bin/cpm && \ |
| 64 | apk del git \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 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 |