blob: 21d77de8767fbb68d5e116cfccf727b42e9ea11f [file] [log] [blame]
Akron17c60812020-06-15 14:29:30 +02001# Build assets in builder image
dependabot[bot]cf833f32022-12-22 14:47:50 +00002FROM node:19 as assetbuilder
3
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 \
19 dev/demo \
20 dev/font \
21 dev/img \
Akron64b957d2020-10-07 22:39:53 +020022 dev/js/bench \
23 dev/js/runner \
24 dev/js/spec \
25 dev/scss && \
26 rm package-lock.json \
27 dev/robots.txt
Akron17c60812020-06-15 14:29:30 +020028
29# Use alpine linux as base image
Akronefd471e2022-03-29 15:07:17 +020030FROM alpine:latest as kalamar-base
Akron17c60812020-06-15 14:29:30 +020031
32# Copy assets from former container
33COPY --from=assetbuilder /kalamar /kalamar
34
35WORKDIR /kalamar
36
37RUN apk update && \
38 apk add --no-cache git \
39 perl \
40 perl-io-socket-ssl \
41 perl-dev \
42 g++ \
43 make \
44 wget \
45 curl && \
46 set -o pipefail && \
47 curl -L https://cpanmin.us | perl - App::cpanminus && \
Akronefd471e2022-03-29 15:07:17 +020048 cpanm https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.21.tar.gz \
Akron2c502e22022-02-13 11:55:19 +010049 Cpanel::JSON::XS \
Akron17c60812020-06-15 14:29:30 +020050 EV \
Akronab6592d2022-02-24 18:23:11 +010051 IO::Socket::Socks
52
Akron2c502e22022-02-13 11:55:19 +010053# Install Kalamar including all dependencies
54RUN cpanm --installdeps . -M https://cpan.metacpan.org
Akron17c60812020-06-15 14:29:30 +020055
Akronefd471e2022-03-29 15:07:17 +020056LABEL maintainer="korap@ids-mannheim.de"
57LABEL repository="https://github.com/KorAP/Kalamar"
58
59FROM kalamar-base AS kalamar
60
61# Remove all build dependencies
62RUN apk del git \
63 perl-dev \
64 g++ \
65 make \
66 wget \
67 curl && \
68 rm -rf /root/.cpanm \
69 /usr/local/share/man && \
70 rm -rf t
71
72RUN addgroup -S korap && \
73 adduser -S kalamar -G korap && \
74 chown -R kalamar.korap /kalamar
75
76USER kalamar
77
78ENV MOJO_PORT 64543
79ENV MOJO_LISTEN http://*:${MOJO_PORT}
80ENV MOJO_MODE production
81
82EXPOSE ${MOJO_PORT}
83
84ENTRYPOINT [ "perl", "script/kalamar" ]
85
86CMD [ "daemon" ]
87
88LABEL description="Docker Image for Kalamar, the KorAP user frontend"
89
90
91FROM kalamar-base AS kalamar-convert
92
93RUN apk update && \
94 apk add --no-cache \
95 perl-doc \
96 libxml2-dev \
97 libxml2 \
98 unzip && \
99 set -o pipefail && \
100 cpanm File::ShareDir::Install
101
102RUN cpanm \
Akrona85abb42023-02-07 14:30:33 +0100103 https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.4.1.tar.gz \
Akronfca186f2023-02-07 12:00:47 +0100104 https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.49.tar.gz
Akronefd471e2022-03-29 15:07:17 +0200105
Akron17c60812020-06-15 14:29:30 +0200106# Remove all build dependencies
107RUN apk del git \
108 perl-dev \
Akron2c502e22022-02-13 11:55:19 +0100109 perl-doc \
Akron17c60812020-06-15 14:29:30 +0200110 g++ \
111 make \
112 wget \
Akron2c502e22022-02-13 11:55:19 +0100113 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +0200114 curl && \
115 rm -rf /root/.cpanm \
Akron64b957d2020-10-07 22:39:53 +0200116 /usr/local/share/man && \
117 rm -rf t
Akron17c60812020-06-15 14:29:30 +0200118
Akronefd471e2022-03-29 15:07:17 +0200119
Akron17c60812020-06-15 14:29:30 +0200120RUN addgroup -S korap && \
121 adduser -S kalamar -G korap && \
122 chown -R kalamar.korap /kalamar
123
124USER kalamar
125
Akronfce76d22022-03-28 19:42:58 +0200126RUN mkdir /kalamar/data
127
Akronf7918692020-06-19 07:12:05 +0200128ENV MOJO_PORT 64543
129ENV MOJO_LISTEN http://*:${MOJO_PORT}
130ENV MOJO_MODE production
131
Akron77645c82022-02-24 18:21:27 +0100132RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML']}}" > kalamar.production.conf
133
Akronf7918692020-06-19 07:12:05 +0200134EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +0200135
136ENTRYPOINT [ "perl", "script/kalamar" ]
137
Akronf7918692020-06-19 07:12:05 +0200138CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +0200139
Akronefd471e2022-03-29 15:07:17 +0200140LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion"
141
Akrone4276a92022-11-30 14:07:15 +0100142# docker build -f Dockerfile -t korap/kalamar:x.xx-conv --target kalamar-convert .
143# docker build -f Dockerfile -t korap/kalamar:x.xx --target kalamar .