blob: 5cf3d81fe1867903aab64c9ad5e4897d82862082 [file] [log] [blame]
Akron17c60812020-06-15 14:29:30 +02001# Build assets in builder image
dependabot[bot]d9681b72023-04-21 09:09:30 +00002FROM 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
28# Use alpine linux as base image
Akronefd471e2022-03-29 15:07:17 +020029FROM alpine:latest as kalamar-base
Akron17c60812020-06-15 14:29:30 +020030
31# Copy assets from former container
32COPY --from=assetbuilder /kalamar /kalamar
33
34WORKDIR /kalamar
35
36RUN apk update && \
37 apk add --no-cache git \
38 perl \
39 perl-io-socket-ssl \
40 perl-dev \
41 g++ \
42 make \
43 wget \
44 curl && \
45 set -o pipefail && \
46 curl -L https://cpanmin.us | perl - App::cpanminus && \
Akronb9ca92b2024-03-14 10:20:18 +010047 cpanm https://github.com/Akron/Mojolicious-Plugin-Localize/archive/refs/tags/v0.22.tar.gz \
Akron2c502e22022-02-13 11:55:19 +010048 Cpanel::JSON::XS \
Akron17c60812020-06-15 14:29:30 +020049 EV \
Akronab6592d2022-02-24 18:23:11 +010050 IO::Socket::Socks
51
Akron2c502e22022-02-13 11:55:19 +010052# Install Kalamar including all dependencies
53RUN cpanm --installdeps . -M https://cpan.metacpan.org
Akron17c60812020-06-15 14:29:30 +020054
Akronefd471e2022-03-29 15:07:17 +020055LABEL maintainer="korap@ids-mannheim.de"
56LABEL repository="https://github.com/KorAP/Kalamar"
57
58FROM kalamar-base AS kalamar
59
60# Remove all build dependencies
61RUN apk del git \
62 perl-dev \
63 g++ \
Akronefd471e2022-03-29 15:07:17 +020064 wget \
65 curl && \
66 rm -rf /root/.cpanm \
Akronefa2f762023-11-13 14:27:54 +010067 /usr/local/share/man
Akronefd471e2022-03-29 15:07:17 +020068
69RUN addgroup -S korap && \
70 adduser -S kalamar -G korap && \
71 chown -R kalamar.korap /kalamar
72
73USER kalamar
74
75ENV MOJO_PORT 64543
76ENV MOJO_LISTEN http://*:${MOJO_PORT}
77ENV MOJO_MODE production
78
79EXPOSE ${MOJO_PORT}
80
81ENTRYPOINT [ "perl", "script/kalamar" ]
82
83CMD [ "daemon" ]
84
85LABEL description="Docker Image for Kalamar, the KorAP user frontend"
86
87
88FROM kalamar-base AS kalamar-convert
89
90RUN apk update && \
91 apk add --no-cache \
92 perl-doc \
93 libxml2-dev \
94 libxml2 \
95 unzip && \
96 set -o pipefail && \
97 cpanm File::ShareDir::Install
98
99RUN cpanm \
Akron9362e012024-01-24 13:06:26 +0100100 https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.5.0.tar.gz \
Akron03dc6772024-06-04 11:50:53 +0200101 https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.55.tar.gz \
102 https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.3.tar.gz
Akronefd471e2022-03-29 15:07:17 +0200103
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++ \
Akron17c60812020-06-15 14:29:30 +0200109 wget \
Akron2c502e22022-02-13 11:55:19 +0100110 libxml2-dev \
Akron17c60812020-06-15 14:29:30 +0200111 curl && \
112 rm -rf /root/.cpanm \
Akronefa2f762023-11-13 14:27:54 +0100113 /usr/local/share/man
Akron17c60812020-06-15 14:29:30 +0200114
Akronefd471e2022-03-29 15:07:17 +0200115
Akron17c60812020-06-15 14:29:30 +0200116RUN addgroup -S korap && \
117 adduser -S kalamar -G korap && \
118 chown -R kalamar.korap /kalamar
119
120USER kalamar
121
Akronfce76d22022-03-28 19:42:58 +0200122RUN mkdir /kalamar/data
123
Akronf7918692020-06-19 07:12:05 +0200124ENV MOJO_PORT 64543
125ENV MOJO_LISTEN http://*:${MOJO_PORT}
126ENV MOJO_MODE production
127
Akron34b4c932023-03-20 16:49:34 +0100128RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNLLU']}}" > kalamar.production.conf
Akron77645c82022-02-24 18:21:27 +0100129
Akronf7918692020-06-19 07:12:05 +0200130EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +0200131
132ENTRYPOINT [ "perl", "script/kalamar" ]
133
Akronf7918692020-06-19 07:12:05 +0200134CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +0200135
Akronefd471e2022-03-29 15:07:17 +0200136LABEL description="Docker Image for Kalamar, the KorAP user frontend, including Conversion"
137
Akron4afb2d02024-06-11 12:46:37 +0200138# docker build -f Dockerfile -t korap/kalamar:x.xx-conv -t korap/kalamar:latest-conv --target kalamar-convert .
139# docker build -f Dockerfile -t korap/kalamar:x.xx -t korap/kalamar:latest --target kalamar .
Akronefa2f762023-11-13 14:27:54 +0100140
141# Slimming (https://github.com/slimtoolkit/slim):
142# slim build --http-probe=true \
143# --exec="perl Makefile.PL && make test" \
144# --include-workdir=true \
145# --tag korap/kalamar:x.xx-conv-slim \
146# korap/kalamar:x.xx-conv