Docker: switch to alpinelinux and cpm

Change-Id: I78210b14a3620fcba36ee7a49f83cd5cd8acc1f3
diff --git a/Dockerfile b/Dockerfile
index 93f9a07..b1da33b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,28 +1,37 @@
-FROM metacpan/metacpan-api AS builder
+FROM alpine:latest AS derekovecs
 
-# Copy repository respecting .dockerignore
-COPY . /derekovecs
+RUN apk update && \
+    apk add --no-cache git \
+            perl \
+            perl-io-socket-ssl \
+            perl-dev \
+            perl-inline-c \
+            g++ \
+            make \
+            cmake gflags-dev snappy-dev zlib-dev zstd-dev lz4-dev bzip2-dev linux-headers \
+            curl && \
+    set -o pipefail
+
+RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm
 
 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 export PROCS=$(nproc) && \
+    git clone https://github.com/kupietz/rocksdb.git -b 5.11.fb --single-branch && \
+    cd rocksdb && \
+    mkdir -p build && \
+    cd build && \
+    cmake .. -DWITH_SNAPPY=1 -DWITH_LZ4=1 -DWITH_ZLIB=1 -DWITH_GFLAGS=1 && \
+    make -j $PROCS && \
+    make install && \
+    ln -s /usr/lib/librocksdb.so.5.11.4 /usr/lib/librocksdb.so.5.11
 
-
-RUN rm -rf rocksdb-5.11.3
+RUN cd /derekovecs && \
+    rm -rf rocksdb
 
 # Install collocatordb
 RUN git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb" && \
@@ -31,23 +40,33 @@
     cd build && \
     cmake .. && \
     make && \
-    make install && \
-    ldconfig && \
-    cd ../..
+    make install
 
-RUN rm -rf collocatordb
+RUN cd /derekovecs && \
+    rm -rf collocatordb
+
+COPY . .
 
 # Install dependencies
-RUN cpanm https://github.com/Akron/Mojolicious-Plugin-Localize.git && \
-    cpanm --installdeps .
-
+RUN cpm install -g https://github.com/Akron/Mojolicious-Plugin-Localize.git && \
+    cpm install -g
 
 # Build derekovecs
 RUN perl Makefile.PL && \
     make && \
     make install
 
-RUN rm -rf example-models
+# RUN MOJO_CONFIG=/derekovecs/example.conf hypnotoad -t script/derekovecs-server # Just do the Inlined::C stuff
+# does not work with slimming
+
+RUN rm -rf example-models /root/.perl-cpm
+RUN rm /bin/cpm && \
+    apk del git \
+#            g++ \
+            cmake \
+            curl && \
+    rm -rf /root/.cpanm \
+            /usr/local/share/man
 
 ENV MOJO_CONFIG=/config/derekovecs.conf