blob: 3f136c5025a645ca931e34d519183f5e35876226 [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 \
Akronb92fbb62024-08-09 15:58:47 +020040 libxml2-dev \
Marc Kupietz03cc3682024-12-16 14:20:54 +010041 perl-xml-libxml \
42 perl-module-pluggable \
43 perl-datetime \
44 perl-readonly \
Akronb92fbb62024-08-09 15:58:47 +020045 unzip \
Akron16891402024-09-09 19:18:28 +020046 curl && \
47 set -o pipefail
48
49RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm
50
51RUN cpm install --test -g Cpanel::JSON::XS File::ShareDir::Install EV IO::Socket::Socks && \
52 cpm install --test -g "https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.22.tar.gz" && \
Marc Kupietz52e66cb2024-12-16 16:26:46 +010053 cpm install --test -g "https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.6.0.tar.gz" && \
Akron16891402024-09-09 19:18:28 +020054 cpm install --test -g "https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.55.tar.gz" && \
55 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 +020056
57# Copy assets from former container
58COPY --from=assetbuilder /kalamar /kalamar
59
60WORKDIR /kalamar
61
Akron2c502e22022-02-13 11:55:19 +010062# Install Kalamar including all dependencies
Akron16891402024-09-09 19:18:28 +020063RUN cpm install --test -g
Akron17c60812020-06-15 14:29:30 +020064
65# Remove all build dependencies
Akron16891402024-09-09 19:18:28 +020066RUN rm /bin/cpm && \
67 apk del git \
Akron17c60812020-06-15 14:29:30 +020068 perl-dev \
Akron2c502e22022-02-13 11:55:19 +010069 perl-doc \
Akron17c60812020-06-15 14:29:30 +020070 g++ \
Akron17c60812020-06-15 14:29:30 +020071 wget \
Akron2c502e22022-02-13 11:55:19 +010072 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +020073 curl && \
74 rm -rf /root/.cpanm \
Akronefa2f762023-11-13 14:27:54 +010075 /usr/local/share/man
Akron17c60812020-06-15 14:29:30 +020076
77RUN addgroup -S korap && \
78 adduser -S kalamar -G korap && \
Marc Kupietz03cc3682024-12-16 14:20:54 +010079 chown -R kalamar:korap /kalamar
Akron17c60812020-06-15 14:29:30 +020080
81USER kalamar
82
Akronfce76d22022-03-28 19:42:58 +020083RUN mkdir /kalamar/data
84
Akronf7918692020-06-19 07:12:05 +020085ENV MOJO_PORT 64543
86ENV MOJO_LISTEN http://*:${MOJO_PORT}
87ENV MOJO_MODE production
88
Akron34b4c932023-03-20 16:49:34 +010089RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf
Akron77645c82022-02-24 18:21:27 +010090
Akronf7918692020-06-19 07:12:05 +020091EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +020092
93ENTRYPOINT [ "perl", "script/kalamar" ]
94
Akronf7918692020-06-19 07:12:05 +020095CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +020096
Akronefd471e2022-03-29 15:07:17 +020097LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion"
Akronb92fbb62024-08-09 15:58:47 +020098LABEL maintainer="korap@ids-mannheim.de"
99LABEL repository="https://github.com/KorAP/Kalamar"
Akronefd471e2022-03-29 15:07:17 +0200100
Akronb92fbb62024-08-09 15:58:47 +0200101# docker build -f Dockerfile -t korap/kalamar:x.xx-large --target kalamar .
Akronefa2f762023-11-13 14:27:54 +0100102
103# Slimming (https://github.com/slimtoolkit/slim):
104# slim build --http-probe=true \
Akrond77eefe2024-08-26 14:01:09 +0200105# --exec="perl Makefile.PL && make test && unzip -v" \
Akronefa2f762023-11-13 14:27:54 +0100106# --include-workdir=true \
Akrond77eefe2024-08-26 14:01:09 +0200107# --include-path="/usr/local/share/perl5/site_perl/KorAP/" \
Akronb92fbb62024-08-09 15:58:47 +0200108# --tag korap/kalamar:x.xx \
109# --tag korap/kalamar:latest \
110# korap/kalamar:x.xx-large