blob: 5a0510dfbdc31aba94a8160bb01cde412c7484ef [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
31# Copy assets from former container
32COPY --from=assetbuilder /kalamar /kalamar
33
34WORKDIR /kalamar
35
36RUN apk update && \
37 apk add --no-cache git \
38 perl \
39 perl-io-socket-ssl \
40 perl-dev \
41 g++ \
42 make \
43 wget \
Akronb92fbb62024-08-09 15:58:47 +020044 perl-doc \
45 libxml2 \
46 libxml2-dev \
47 unzip \
Akron17c60812020-06-15 14:29:30 +020048 curl && \
49 set -o pipefail && \
50 curl -L https://cpanmin.us | perl - App::cpanminus && \
Akronb9ca92b2024-03-14 10:20:18 +010051 cpanm https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.22.tar.gz \
Akron2c502e22022-02-13 11:55:19 +010052 Cpanel::JSON::XS \
Akronb92fbb62024-08-09 15:58:47 +020053 File::ShareDir::Install \
Akron17c60812020-06-15 14:29:30 +020054 EV \
Akronb92fbb62024-08-09 15:58:47 +020055 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
Akronab6592d2022-02-24 18:23:11 +010059
Akron2c502e22022-02-13 11:55:19 +010060# Install Kalamar including all dependencies
61RUN cpanm --installdeps . -M https://cpan.metacpan.org
Akron17c60812020-06-15 14:29:30 +020062
63# Remove all build dependencies
64RUN apk del git \
65 perl-dev \
Akron2c502e22022-02-13 11:55:19 +010066 perl-doc \
Akron17c60812020-06-15 14:29:30 +020067 g++ \
Akron17c60812020-06-15 14:29:30 +020068 wget \
Akron2c502e22022-02-13 11:55:19 +010069 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +020070 curl && \
71 rm -rf /root/.cpanm \
Akronefa2f762023-11-13 14:27:54 +010072 /usr/local/share/man
Akron17c60812020-06-15 14:29:30 +020073
74RUN addgroup -S korap && \
75 adduser -S kalamar -G korap && \
76 chown -R kalamar.korap /kalamar
77
78USER kalamar
79
Akronfce76d22022-03-28 19:42:58 +020080RUN mkdir /kalamar/data
81
Akronf7918692020-06-19 07:12:05 +020082ENV MOJO_PORT 64543
83ENV MOJO_LISTEN http://*:${MOJO_PORT}
84ENV MOJO_MODE production
85
Akron34b4c932023-03-20 16:49:34 +010086RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf
Akron77645c82022-02-24 18:21:27 +010087
Akronf7918692020-06-19 07:12:05 +020088EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +020089
90ENTRYPOINT [ "perl", "script/kalamar" ]
91
Akronf7918692020-06-19 07:12:05 +020092CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +020093
Akronefd471e2022-03-29 15:07:17 +020094LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion"
Akronb92fbb62024-08-09 15:58:47 +020095LABEL maintainer="korap@ids-mannheim.de"
96LABEL repository="https://github.com/KorAP/Kalamar"
Akronefd471e2022-03-29 15:07:17 +020097
Akronb92fbb62024-08-09 15:58:47 +020098# docker build -f Dockerfile -t korap/kalamar:x.xx-large --target kalamar .
Akronefa2f762023-11-13 14:27:54 +010099
100# Slimming (https://github.com/slimtoolkit/slim):
101# slim build --http-probe=true \
102# --exec="perl Makefile.PL && make test" \
103# --include-workdir=true \
Akronb92fbb62024-08-09 15:58:47 +0200104# --tag korap/kalamar:x.xx \
105# --tag korap/kalamar:latest \
106# korap/kalamar:x.xx-large