blob: 2eff6b46e545869df7a1d1e65e76692d79c69a70 [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
6RUN npm install -g sass && \
7 npm install grunt && \
8 npm install -g grunt-cli
9
10# Copy repository respecting .dockerignore
11COPY . /kalamar
12
13RUN cd /kalamar && \
14 npm install && \
15 grunt && \
16 rm -rf node_modules \
17 dev/css \
18 dev/demo \
19 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
29FROM alpine:latest
30
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 && \
47 cpanm git://github.com/Akron/Mojolicious-Plugin-Localize.git \
48 git://github.com/Akron/Mojolicious-Plugin-TagHelpers-ContentBlock.git && \
49 cpanm Cpanel::JSON::XS \
50 EV \
51 IO::Socket::Socks && \
52 cpanm --installdeps . -M https://cpan.metacpan.org
53
54# Remove all build dependencies
55RUN apk del git \
56 perl-dev \
57 g++ \
58 make \
59 wget \
60 curl && \
61 rm -rf /root/.cpanm \
Akron64b957d2020-10-07 22:39:53 +020062 /usr/local/share/man && \
63 rm -rf t
Akron17c60812020-06-15 14:29:30 +020064
65RUN addgroup -S korap && \
66 adduser -S kalamar -G korap && \
67 chown -R kalamar.korap /kalamar
68
69USER kalamar
70
Akronf7918692020-06-19 07:12:05 +020071ENV MOJO_PORT 64543
72ENV MOJO_LISTEN http://*:${MOJO_PORT}
73ENV MOJO_MODE production
74
75EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +020076
77ENTRYPOINT [ "perl", "script/kalamar" ]
78
Akronf7918692020-06-19 07:12:05 +020079CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +020080
Akron728bbe02020-07-03 17:34:07 +020081LABEL maintainer="korap@ids-mannheim.de"
Akron17c60812020-06-15 14:29:30 +020082LABEL description="Docker Image for Kalamar, the KorAP user frontend"
83LABEL repository="https://github.com/KorAP/Kalamar"