blob: e80e9eba850e9aa92f2547f04f0b6bb400c5f7d4 [file] [log] [blame]
Akron17c60812020-06-15 14:29:30 +02001# Build assets in builder image
dependabot[bot]d9681b72023-04-21 09:09:30 +00002FROM node:20 as assetbuilder
dependabot[bot]cf833f32022-12-22 14:47:50 +00003
4WORKDIR '/app'
Akron17c60812020-06-15 14:29:30 +02005
6# This follows the "multi-stage build" pattern
7
Akron7ca73872021-03-08 11:29:11 +01008RUN npm install grunt && \
Akron17c60812020-06-15 14:29:30 +02009 npm install -g grunt-cli
10
11# Copy repository respecting .dockerignore
12COPY . /kalamar
13
14RUN cd /kalamar && \
15 npm install && \
16 grunt && \
17 rm -rf node_modules \
18 dev/css \
Akron17c60812020-06-15 14:29:30 +020019 dev/font \
20 dev/img \
Akron64b957d2020-10-07 22:39:53 +020021 dev/js/bench \
22 dev/js/runner \
23 dev/js/spec \
24 dev/scss && \
25 rm package-lock.json \
26 dev/robots.txt
Akron17c60812020-06-15 14:29:30 +020027
28# Use alpine linux as base image
Akronb92fbb62024-08-09 15:58:47 +020029FROM alpine:latest as kalamar
Akron17c60812020-06-15 14:29:30 +020030
Akron17c60812020-06-15 14:29:30 +020031RUN apk update && \
32 apk add --no-cache git \
33 perl \
34 perl-io-socket-ssl \
35 perl-dev \
36 g++ \
37 make \
38 wget \
Akronb92fbb62024-08-09 15:58:47 +020039 perl-doc \
40 libxml2 \
41 libxml2-dev \
42 unzip \
Akron1b9c2432024-09-03 09:27:18 +020043 curl
44
45# Copy assets from former container
46COPY --from=assetbuilder /kalamar /kalamar
47
48WORKDIR /kalamar
49
50RUN set -o pipefail && \
Akron17c60812020-06-15 14:29:30 +020051 curl -L https://cpanmin.us | perl - App::cpanminus && \
Akronb9ca92b2024-03-14 10:20:18 +010052 cpanm https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.22.tar.gz \
Akron2c502e22022-02-13 11:55:19 +010053 Cpanel::JSON::XS \
Akronb92fbb62024-08-09 15:58:47 +020054 File::ShareDir::Install \
Akron17c60812020-06-15 14:29:30 +020055 EV \
Akronb92fbb62024-08-09 15:58:47 +020056 IO::Socket::Socks \
57 https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.5.0.tar.gz \
58 https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.55.tar.gz \
59 https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.3.tar.gz
Akronab6592d2022-02-24 18:23:11 +010060
Akron2c502e22022-02-13 11:55:19 +010061# Install Kalamar including all dependencies
62RUN cpanm --installdeps . -M https://cpan.metacpan.org
Akron17c60812020-06-15 14:29:30 +020063
64# Remove all build dependencies
65RUN apk del git \
66 perl-dev \
Akron2c502e22022-02-13 11:55:19 +010067 perl-doc \
Akron17c60812020-06-15 14:29:30 +020068 g++ \
Akron17c60812020-06-15 14:29:30 +020069 wget \
Akron2c502e22022-02-13 11:55:19 +010070 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +020071 curl && \
72 rm -rf /root/.cpanm \
Akronefa2f762023-11-13 14:27:54 +010073 /usr/local/share/man
Akron17c60812020-06-15 14:29:30 +020074
75RUN addgroup -S korap && \
76 adduser -S kalamar -G korap && \
77 chown -R kalamar.korap /kalamar
78
79USER kalamar
80
Akronfce76d22022-03-28 19:42:58 +020081RUN mkdir /kalamar/data
82
Akronf7918692020-06-19 07:12:05 +020083ENV MOJO_PORT 64543
84ENV MOJO_LISTEN http://*:${MOJO_PORT}
85ENV MOJO_MODE production
86
Akron34b4c932023-03-20 16:49:34 +010087RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf
Akron77645c82022-02-24 18:21:27 +010088
Akronf7918692020-06-19 07:12:05 +020089EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +020090
91ENTRYPOINT [ "perl", "script/kalamar" ]
92
Akronf7918692020-06-19 07:12:05 +020093CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +020094
Akronefd471e2022-03-29 15:07:17 +020095LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion"
Akronb92fbb62024-08-09 15:58:47 +020096LABEL maintainer="korap@ids-mannheim.de"
97LABEL repository="https://github.com/KorAP/Kalamar"
Akronefd471e2022-03-29 15:07:17 +020098
Akronb92fbb62024-08-09 15:58:47 +020099# docker build -f Dockerfile -t korap/kalamar:x.xx-large --target kalamar .
Akronefa2f762023-11-13 14:27:54 +0100100
101# Slimming (https://github.com/slimtoolkit/slim):
102# slim build --http-probe=true \
Akrond77eefe2024-08-26 14:01:09 +0200103# --exec="perl Makefile.PL && make test && unzip -v" \
Akronefa2f762023-11-13 14:27:54 +0100104# --include-workdir=true \
Akrond77eefe2024-08-26 14:01:09 +0200105# --include-path="/usr/local/share/perl5/site_perl/KorAP/" \
Akronb92fbb62024-08-09 15:58:47 +0200106# --tag korap/kalamar:x.xx \
107# --tag korap/kalamar:latest \
108# korap/kalamar:x.xx-large