Add Dockerfile
Change-Id: I1160c014bca9f4dbff8da2dadcbde5d91eabaef0
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d68d7f5
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,57 @@
+FROM metacpan/metacpan-api as builder
+
+# Copy repository respecting .dockerignore
+COPY . /derekovecs
+
+WORKDIR /derekovecs
+
+RUN apt update && apt -y install cmake libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev
+
+RUN git config --global user.email "korap+docker@ids-mannheim.de" && \
+ git config --global user.name "Docker"
+
+# Install RocksDB
+RUN curl -L https://github.com/facebook/rocksdb/archive/refs/tags/v5.11.3.tar.gz | tar zx && \
+ cd rocksdb-5.11.3 && \
+ export PROCS=$(nproc) && \
+ make -j $PROCS static_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w && \
+ make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w && \
+ make -j $PROCS shared_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w && \
+ make install-shared DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w && \
+ ldconfig && \
+ cd ..
+
+
+RUN rm -rf rocksdb-5.11.3
+
+# Install collocatordb
+RUN git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb" && \
+ cd collocatordb && \
+ mkdir -p build && \
+ cd build && \
+ cmake .. && \
+ make && \
+ make install && \
+ ldconfig && \
+ cd ../..
+
+RUN rm -rf collocatordb
+
+# Install dependencies
+RUN cpanm https://github.com/Akron/Mojolicious-Plugin-Localize.git && \
+ cpanm --installdeps .
+
+
+# Build derekovecs
+RUN perl Makefile.PL && \
+ make && \
+ make install
+
+
+ENV MOJO_CONFIG=/config/example.conf
+
+# RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML']}}" > kalamar.production.conf
+
+EXPOSE 3000
+
+ENTRYPOINT [ "hypnotoad", "-f", "script/derekovecs-server" ]
diff --git a/README.md b/README.md
index 2524e77..8984899 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,25 @@
$ GET 'http://localhost:3000/getCollocationAssociation?w=Grund&c=diesem'
```
+## Build and run using docker / podman
+
+### Build image
+
+```bash
+docker build -t ids-kl/derekovecs .
+```
+
+### Copy configuration to make it mountable
+```bash
+mkdir config
+cp example.conf config/derekovecs.conf
+```
+
+### Run
+``` bash
+docker run -d=false -p 3000:3000 --rm -v $(pwd)/config:/config:z ids-kl/derekovecs
+```
+
## Development and License
**Author**: [Marc Kupietz](https://www.ids-mannheim.de/digspra/personal/kupietz.html)
diff --git a/example.conf b/example.conf
index a9522d4..a68f5e3 100644
--- a/example.conf
+++ b/example.conf
@@ -1,6 +1,6 @@
{
hypnotoad => {
- listen => ['http://*:5673'],
+ listen => ['http://*:3000'],
trusted_proxies => ['10.0/8', '127.0.0.1'],
proxy => 1,
pid_file => 'derekovecs-example.'. `hostname -s | tr -d "\n"` .'.pid',