blob: 641adecd6e4c4d38e22d061e83b719905ce618a6 [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 \
Marc Kupietz346b67d2023-02-14 15:20:26 +0100104 https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.49.tar.gz \
Akronaaf4a832023-01-12 17:26:20 +0100105 https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.0.tar.gz
Akronefd471e2022-03-29 15:07:17 +0200106
Akron17c60812020-06-15 14:29:30 +0200107# Remove all build dependencies
108RUN apk del git \
109 perl-dev \
Akron2c502e22022-02-13 11:55:19 +0100110 perl-doc \
Akron17c60812020-06-15 14:29:30 +0200111 g++ \
112 make \
113 wget \
Akron2c502e22022-02-13 11:55:19 +0100114 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +0200115 curl && \
116 rm -rf /root/.cpanm \
Akron64b957d2020-10-07 22:39:53 +0200117 /usr/local/share/man && \
118 rm -rf t
Akron17c60812020-06-15 14:29:30 +0200119
Akronefd471e2022-03-29 15:07:17 +0200120
Akron17c60812020-06-15 14:29:30 +0200121RUN addgroup -S korap && \
122 adduser -S kalamar -G korap && \
123 chown -R kalamar.korap /kalamar
124
125USER kalamar
126
Akronfce76d22022-03-28 19:42:58 +0200127RUN mkdir /kalamar/data
128
Akronf7918692020-06-19 07:12:05 +0200129ENV MOJO_PORT 64543
130ENV MOJO_LISTEN http://*:${MOJO_PORT}
131ENV MOJO_MODE production
132
Akron34b4c932023-03-20 16:49:34 +0100133RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf
Akron77645c82022-02-24 18:21:27 +0100134
Akronf7918692020-06-19 07:12:05 +0200135EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +0200136
137ENTRYPOINT [ "perl", "script/kalamar" ]
138
Akronf7918692020-06-19 07:12:05 +0200139CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +0200140
Akronefd471e2022-03-29 15:07:17 +0200141LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion"
142
Akrone4276a92022-11-30 14:07:15 +0100143# docker build -f Dockerfile -t korap/kalamar:x.xx-conv --target kalamar-convert .
144# docker build -f Dockerfile -t korap/kalamar:x.xx --target kalamar .