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 |
| 28 | FROM alpine:latest |
| 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 \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 40 | perl-doc \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 41 | g++ \ |
| 42 | make \ |
| 43 | wget \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 44 | libxml2-dev \ |
Akron | ab6592d | 2022-02-24 18:23:11 +0100 | [diff] [blame^] | 45 | libxml2 \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 46 | unzip \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 47 | curl && \ |
| 48 | set -o pipefail && \ |
| 49 | curl -L https://cpanmin.us | perl - App::cpanminus && \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 50 | cpanm File::ShareDir::Install \ |
| 51 | Cpanel::JSON::XS \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 52 | EV \ |
Akron | ab6592d | 2022-02-24 18:23:11 +0100 | [diff] [blame^] | 53 | IO::Socket::Socks |
| 54 | |
| 55 | RUN cpanm https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.21.tar.gz \ |
| 56 | https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.3.2b.tar.gz \ |
| 57 | https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.45.tar.gz |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 58 | |
| 59 | # Install Kalamar including all dependencies |
| 60 | RUN cpanm --installdeps . -M https://cpan.metacpan.org |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 61 | |
| 62 | # Remove all build dependencies |
| 63 | RUN apk del git \ |
| 64 | perl-dev \ |
Akron | 2c502e2 | 2022-02-13 11:55:19 +0100 | [diff] [blame] | 65 | perl-doc \ |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 66 | g++ \ |
| 67 | make \ |
| 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 | 64b957d | 2020-10-07 22:39:53 +0200 | [diff] [blame] | 72 | /usr/local/share/man && \ |
| 73 | rm -rf t |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 74 | |
| 75 | RUN addgroup -S korap && \ |
| 76 | adduser -S kalamar -G korap && \ |
| 77 | chown -R kalamar.korap /kalamar |
| 78 | |
| 79 | USER kalamar |
| 80 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 81 | ENV MOJO_PORT 64543 |
| 82 | ENV MOJO_LISTEN http://*:${MOJO_PORT} |
| 83 | ENV MOJO_MODE production |
| 84 | |
Akron | 77645c8 | 2022-02-24 18:21:27 +0100 | [diff] [blame] | 85 | RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML']}}" > kalamar.production.conf |
| 86 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 87 | EXPOSE ${MOJO_PORT} |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 88 | |
| 89 | ENTRYPOINT [ "perl", "script/kalamar" ] |
| 90 | |
Akron | f791869 | 2020-06-19 07:12:05 +0200 | [diff] [blame] | 91 | CMD [ "daemon" ] |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 92 | |
Akron | 728bbe0 | 2020-07-03 17:34:07 +0200 | [diff] [blame] | 93 | LABEL maintainer="korap@ids-mannheim.de" |
Akron | 17c6081 | 2020-06-15 14:29:30 +0200 | [diff] [blame] | 94 | LABEL description="Docker Image for Kalamar, the KorAP user frontend" |
| 95 | LABEL repository="https://github.com/KorAP/Kalamar" |