blob: 7daf0ba74f3139ffec47f268b13d3236e09886d7 [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
Akronefd471e2022-03-29 15:07:17 +020028FROM alpine:latest as kalamar-base
Akron17c60812020-06-15 14:29:30 +020029
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 \
40 g++ \
41 make \
42 wget \
43 curl && \
44 set -o pipefail && \
45 curl -L https://cpanmin.us | perl - App::cpanminus && \
Akronefd471e2022-03-29 15:07:17 +020046 cpanm https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.21.tar.gz \
Akron2c502e22022-02-13 11:55:19 +010047 Cpanel::JSON::XS \
Akron17c60812020-06-15 14:29:30 +020048 EV \
Akronab6592d2022-02-24 18:23:11 +010049 IO::Socket::Socks
50
Akron2c502e22022-02-13 11:55:19 +010051# Install Kalamar including all dependencies
52RUN cpanm --installdeps . -M https://cpan.metacpan.org
Akron17c60812020-06-15 14:29:30 +020053
Akronefd471e2022-03-29 15:07:17 +020054LABEL maintainer="korap@ids-mannheim.de"
55LABEL repository="https://github.com/KorAP/Kalamar"
56
57FROM kalamar-base AS kalamar
58
59# Remove all build dependencies
60RUN apk del git \
61 perl-dev \
62 g++ \
63 make \
64 wget \
65 curl && \
66 rm -rf /root/.cpanm \
67 /usr/local/share/man && \
68 rm -rf t
69
70RUN addgroup -S korap && \
71 adduser -S kalamar -G korap && \
72 chown -R kalamar.korap /kalamar
73
74USER kalamar
75
76ENV MOJO_PORT 64543
77ENV MOJO_LISTEN http://*:${MOJO_PORT}
78ENV MOJO_MODE production
79
80EXPOSE ${MOJO_PORT}
81
82ENTRYPOINT [ "perl", "script/kalamar" ]
83
84CMD [ "daemon" ]
85
86LABEL description="Docker Image for Kalamar, the KorAP user frontend"
87
88
89FROM kalamar-base AS kalamar-convert
90
91RUN apk update && \
92 apk add --no-cache \
93 perl-doc \
94 libxml2-dev \
95 libxml2 \
96 unzip && \
97 set -o pipefail && \
98 cpanm File::ShareDir::Install
99
100RUN cpanm \
101 https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.3.2b.tar.gz \
102 https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.45.tar.gz
103
Akron17c60812020-06-15 14:29:30 +0200104# Remove all build dependencies
105RUN apk del git \
106 perl-dev \
Akron2c502e22022-02-13 11:55:19 +0100107 perl-doc \
Akron17c60812020-06-15 14:29:30 +0200108 g++ \
109 make \
110 wget \
Akron2c502e22022-02-13 11:55:19 +0100111 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +0200112 curl && \
113 rm -rf /root/.cpanm \
Akron64b957d2020-10-07 22:39:53 +0200114 /usr/local/share/man && \
115 rm -rf t
Akron17c60812020-06-15 14:29:30 +0200116
Akronefd471e2022-03-29 15:07:17 +0200117
Akron17c60812020-06-15 14:29:30 +0200118RUN addgroup -S korap && \
119 adduser -S kalamar -G korap && \
120 chown -R kalamar.korap /kalamar
121
122USER kalamar
123
Akronfce76d22022-03-28 19:42:58 +0200124RUN mkdir /kalamar/data
125
Akronf7918692020-06-19 07:12:05 +0200126ENV MOJO_PORT 64543
127ENV MOJO_LISTEN http://*:${MOJO_PORT}
128ENV MOJO_MODE production
129
Akron77645c82022-02-24 18:21:27 +0100130RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML']}}" > kalamar.production.conf
131
Akronf7918692020-06-19 07:12:05 +0200132EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +0200133
134ENTRYPOINT [ "perl", "script/kalamar" ]
135
Akronf7918692020-06-19 07:12:05 +0200136CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +0200137
Akronefd471e2022-03-29 15:07:17 +0200138LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion"
139
Akron7f283d62022-04-04 12:12:12 +0200140# docker build -f Dockerfile -t korap/kalamar:0.44-conv --target kalamar-convert .
Akronefd471e2022-03-29 15:07:17 +0200141# docker build -f Dockerfile -t korap/kalamar:0.44 --target kalamar .