blob: 2426f5d987165e8a10501fb0fb7b92a59655a37d [file] [log] [blame]
Akron17c60812020-06-15 14:29:30 +02001# Build assets in builder image
2FROM node:12 as assetbuilder
3
4# This follows the "multi-stage build" pattern
5
Akron7ca73872021-03-08 11:29:11 +01006RUN npm install grunt && \
Akron17c60812020-06-15 14:29:30 +02007 npm install -g grunt-cli
8
9# Copy repository respecting .dockerignore
10COPY . /kalamar
11
12RUN cd /kalamar && \
13 npm install && \
14 grunt && \
15 rm -rf node_modules \
16 dev/css \
17 dev/demo \
18 dev/font \
19 dev/img \
Akron64b957d2020-10-07 22:39:53 +020020 dev/js/bench \
21 dev/js/runner \
22 dev/js/spec \
23 dev/scss && \
24 rm package-lock.json \
25 dev/robots.txt
Akron17c60812020-06-15 14:29:30 +020026
27# Use alpine linux as base image
28FROM alpine:latest
29
30# Copy assets from former container
31COPY --from=assetbuilder /kalamar /kalamar
32
33WORKDIR /kalamar
34
35RUN apk update && \
36 apk add --no-cache git \
37 perl \
38 perl-io-socket-ssl \
39 perl-dev \
Akron2c502e22022-02-13 11:55:19 +010040 perl-doc \
Akron17c60812020-06-15 14:29:30 +020041 g++ \
42 make \
43 wget \
Akron2c502e22022-02-13 11:55:19 +010044 libxml2-dev \
Akronab6592d2022-02-24 18:23:11 +010045 libxml2 \
Akron2c502e22022-02-13 11:55:19 +010046 unzip \
Akron17c60812020-06-15 14:29:30 +020047 curl && \
48 set -o pipefail && \
49 curl -L https://cpanmin.us | perl - App::cpanminus && \
Akron2c502e22022-02-13 11:55:19 +010050 cpanm File::ShareDir::Install \
51 Cpanel::JSON::XS \
Akron17c60812020-06-15 14:29:30 +020052 EV \
Akronab6592d2022-02-24 18:23:11 +010053 IO::Socket::Socks
54
55RUN 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
Akron2c502e22022-02-13 11:55:19 +010058
59# Install Kalamar including all dependencies
60RUN cpanm --installdeps . -M https://cpan.metacpan.org
Akron17c60812020-06-15 14:29:30 +020061
62# Remove all build dependencies
63RUN apk del git \
64 perl-dev \
Akron2c502e22022-02-13 11:55:19 +010065 perl-doc \
Akron17c60812020-06-15 14:29:30 +020066 g++ \
67 make \
68 wget \
Akron2c502e22022-02-13 11:55:19 +010069 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +020070 curl && \
71 rm -rf /root/.cpanm \
Akron64b957d2020-10-07 22:39:53 +020072 /usr/local/share/man && \
73 rm -rf t
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
Akronf7918692020-06-19 07:12:05 +020081ENV MOJO_PORT 64543
82ENV MOJO_LISTEN http://*:${MOJO_PORT}
83ENV MOJO_MODE production
84
Akron77645c82022-02-24 18:21:27 +010085RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML']}}" > kalamar.production.conf
86
Akronf7918692020-06-19 07:12:05 +020087EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +020088
89ENTRYPOINT [ "perl", "script/kalamar" ]
90
Akronf7918692020-06-19 07:12:05 +020091CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +020092
Akron728bbe02020-07-03 17:34:07 +020093LABEL maintainer="korap@ids-mannheim.de"
Akron17c60812020-06-15 14:29:30 +020094LABEL description="Docker Image for Kalamar, the KorAP user frontend"
95LABEL repository="https://github.com/KorAP/Kalamar"