blob: 3663a2f8cca868b41b6defcbe6cb4edcd28c31db [file] [log] [blame]
Akron17c60812020-06-15 14:29:30 +02001# Build assets in builder image
Akron16891402024-09-09 19:18:28 +02002FROM 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
Akron16891402024-09-09 19:18:28 +020028# Use alpine linux AS base image
29FROM 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 \
Akron16891402024-09-09 19:18:28 +020043 curl && \
44 set -o pipefail
45
46RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm
47
48RUN 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"
Akron1b9c2432024-09-03 09:27:18 +020053
54# Copy assets from former container
55COPY --from=assetbuilder /kalamar /kalamar
56
57WORKDIR /kalamar
58
Akron2c502e22022-02-13 11:55:19 +010059# Install Kalamar including all dependencies
Akron16891402024-09-09 19:18:28 +020060RUN cpm install --test -g
Akron17c60812020-06-15 14:29:30 +020061
62# Remove all build dependencies
Akron16891402024-09-09 19:18:28 +020063RUN rm /bin/cpm && \
64 apk del git \
Akron17c60812020-06-15 14:29:30 +020065 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 \
Akrond77eefe2024-08-26 14:01:09 +0200102# --exec="perl Makefile.PL && make test && unzip -v" \
Akronefa2f762023-11-13 14:27:54 +0100103# --include-workdir=true \
Akrond77eefe2024-08-26 14:01:09 +0200104# --include-path="/usr/local/share/perl5/site_perl/KorAP/" \
Akronb92fbb62024-08-09 15:58:47 +0200105# --tag korap/kalamar:x.xx \
106# --tag korap/kalamar:latest \
107# korap/kalamar:x.xx-large