blob: 2d9b28bc92e8c8890b65be0a07f8e5f40c812170 [file] [log] [blame]
Marc Kupietz846e1492024-09-11 19:10:31 +02001FROM alpine:latest AS derekovecs
Marc Kupietza3774412022-06-10 21:46:22 +02002
Marc Kupietz846e1492024-09-11 19:10:31 +02003RUN apk update && \
4 apk add --no-cache git \
5 perl \
6 perl-io-socket-ssl \
7 perl-dev \
8 perl-inline-c \
9 g++ \
10 make \
Marc Kupietz96972c62026-07-31 09:50:14 +090011 cmake rocksdb-dev gflags-dev snappy-dev zlib-dev zstd-dev lz4-dev bzip2-dev linux-headers \
Marc Kupietz846e1492024-09-11 19:10:31 +020012 curl && \
13 set -o pipefail
14
15RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm
Marc Kupietza3774412022-06-10 21:46:22 +020016
17WORKDIR /derekovecs
18
Marc Kupietza3774412022-06-10 21:46:22 +020019RUN git config --global user.email "korap+docker@ids-mannheim.de" && \
20 git config --global user.name "Docker"
21
Marc Kupietz96972c62026-07-31 09:50:14 +090022# Install collocatordb, which builds against the rocksdb package
Marc Kupietza3774412022-06-10 21:46:22 +020023RUN git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb" && \
24 cd collocatordb && \
25 mkdir -p build && \
26 cd build && \
27 cmake .. && \
Marc Kupietz96972c62026-07-31 09:50:14 +090028 make -j $(nproc) && \
Marc Kupietz846e1492024-09-11 19:10:31 +020029 make install
Marc Kupietza3774412022-06-10 21:46:22 +020030
Marc Kupietz846e1492024-09-11 19:10:31 +020031RUN cd /derekovecs && \
32 rm -rf collocatordb
33
34COPY . .
Marc Kupietza3774412022-06-10 21:46:22 +020035
Marc Kupietz606a9092026-07-31 10:09:07 +090036# Session::Token, pulled in by Mojolicious::Plugin::Util::RandomString, declares
37# the functions of its bundled isaac implementation without prototypes, which
38# gcc rejects since it defaults to C23. Build this one with C17, the rest of the
39# dependencies compile with the defaults.
40RUN PERL_MM_OPT="CCFLAGS=-std=gnu17" cpm install -g Session::Token
41
Marc Kupietze20daf12026-07-31 09:55:55 +090042# Install dependencies. Devel::CheckLib, which Makefile.PL needs to find
43# libcollocatordb, comes bundled in inc/
Marc Kupietz846e1492024-09-11 19:10:31 +020044RUN cpm install -g https://github.com/Akron/Mojolicious-Plugin-Localize.git && \
45 cpm install -g
Marc Kupietza3774412022-06-10 21:46:22 +020046
47# Build derekovecs
48RUN perl Makefile.PL && \
49 make && \
50 make install
51
Marc Kupietz846e1492024-09-11 19:10:31 +020052# RUN MOJO_CONFIG=/derekovecs/example.conf hypnotoad -t script/derekovecs-server # Just do the Inlined::C stuff
53# does not work with slimming
Marc Kupietz10ccb982024-09-12 14:15:13 +020054RUN perl -p -i -e 's@"/example-models@"/derekovecs/example-models@' example-models/example-docker.conf
55RUN rm -rf example-models
56RUN rm -rf /root/.perl-cpm
Marc Kupietz846e1492024-09-11 19:10:31 +020057RUN rm /bin/cpm && \
58 apk del git \
59# g++ \
60 cmake \
61 curl && \
62 rm -rf /root/.cpanm \
63 /usr/local/share/man
Marc Kupietza3774412022-06-10 21:46:22 +020064
Marc Kupietza1f97022022-06-10 23:42:01 +020065ENV MOJO_CONFIG=/config/derekovecs.conf
Marc Kupietza3774412022-06-10 21:46:22 +020066
67EXPOSE 3000
68
69ENTRYPOINT [ "hypnotoad", "-f", "script/derekovecs-server" ]