blob: 44003e287b1268a8fce4fea7dc25a0014fd6ce42 [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
28FROM alpine:latest
29
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 && \
46 cpanm git://github.com/Akron/Mojolicious-Plugin-Localize.git \
47 git://github.com/Akron/Mojolicious-Plugin-TagHelpers-ContentBlock.git && \
48 cpanm Cpanel::JSON::XS \
49 EV \
50 IO::Socket::Socks && \
51 cpanm --installdeps . -M https://cpan.metacpan.org
52
53# Remove all build dependencies
54RUN apk del git \
55 perl-dev \
56 g++ \
57 make \
58 wget \
59 curl && \
60 rm -rf /root/.cpanm \
Akron64b957d2020-10-07 22:39:53 +020061 /usr/local/share/man && \
62 rm -rf t
Akron17c60812020-06-15 14:29:30 +020063
64RUN addgroup -S korap && \
65 adduser -S kalamar -G korap && \
66 chown -R kalamar.korap /kalamar
67
68USER kalamar
69
Akronf7918692020-06-19 07:12:05 +020070ENV MOJO_PORT 64543
71ENV MOJO_LISTEN http://*:${MOJO_PORT}
72ENV MOJO_MODE production
73
74EXPOSE ${MOJO_PORT}
Akron17c60812020-06-15 14:29:30 +020075
76ENTRYPOINT [ "perl", "script/kalamar" ]
77
Akronf7918692020-06-19 07:12:05 +020078CMD [ "daemon" ]
Akron17c60812020-06-15 14:29:30 +020079
Akron728bbe02020-07-03 17:34:07 +020080LABEL maintainer="korap@ids-mannheim.de"
Akron17c60812020-06-15 14:29:30 +020081LABEL description="Docker Image for Kalamar, the KorAP user frontend"
82LABEL repository="https://github.com/KorAP/Kalamar"