Build as docker container

Change-Id: Ied30167fbaf02fb7744e6295168c8c450687a4c6
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 92f7eec..77120cb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,38 +1,31 @@
-# use the verse rocker image, as it contains tidyverse, devtools and some texlive
-image: rocker/tidyverse
+# gitlab ci pipeline to build corpuscomposition docker container
+# automatically triggered on tag pushes or run manually
+#
+# Download container from artifacts and import it
+# e.g. with
+# unxz -c < corpuscomposition-master-fffe0d98.xz | docker load
+#
+image: docker:latest
 
-# define stages of runner. at the moment,
-# just build (no test or deploy).
-stages:
-  - build
+services:
+  - docker:dind
 
-build-job:
+build:
+  rules:
+    - if: $CI_COMMIT_TAG =~ /.+/
+      variables:
+        VID: $CI_COMMIT_TAG
+    - when: manual
+      variables:
+        VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
   stage: build
-
-  cache:
-    key: korap
-    paths:
-      - ./cache
-
   before_script:
-    - source `find .. -name section_helper.sh`
-
-    - start_section install_linux_packages "Installing missing Linux packages"
-    - apt-get update
-    - apt-get install -y libvulkan1 libu2f-udev build-essential libglpk40 libcurl4-gnutls-dev libxml2-dev libsodium-dev libsecret-1-dev libfontconfig1-dev libssl-dev libxt6 libpq-dev curl
-    - end_section install_linux_packages
-
-    - start_section install_r_packages "Installing missing R packages"
-    - R -e "install.packages(c('devtools', 'RKorAPClient', 'httr', 'shiny', 'shinythemes', 'highcharter'))"
-    - R -e 'devtools::install_git("https://korap.ids-mannheim.de/gerrit/IDS-Mannheim/idsThemeR")'
-    - end_section install_r_packages
-
+    - apk update
+    - apk add --no-cache git
   script:
-    - start_section render "Running scripts"
-    - echo 'options(shiny.port=18000)' >> ~/.Rprofile
-    - R_CACHE_ROOTPATH=./cache Rscript shinyCorpusComposition.R &
-    - PID=$!
-    - sleep 10
-    - curl http://127.0.0.1:18000/
-    - kill $PID
-    - end_section render
+    - docker build -f Dockerfile -t korap/corpuscomposition:$VID .
+    - docker save korap/corpuscomposition:$VID | xz -T0 -M16G -9 > corpuscomposition-$VID.xz
+  artifacts:
+    paths:
+      - corpuscomposition-$VID.xz
+