Add gitlab workflow to build docker image

Automatically run only on pushed tags, but can also be run manually at any time.

Change-Id: Iff54b5be7c24f3dcdc3912462d472abd523f4ac2
diff --git a/.gitignore b/.gitignore
index de38250..d0db035 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@
 /t/kalamar_user_client.t
 !.gitignore
 !.github
+!.gitlab-ci.yml
 !.dockerignore
 /npm-debug.log
 /package-lock.json
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..c739693
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,31 @@
+# gitlab ci pipeline to build kalamar docker container
+# automatically triggered on tag pushs or run manually
+#
+# Download container from artifacts and import it
+# e.g. with
+# unxz -c < kalamar-master-fffe0d98.xz | docker load
+#
+image: docker:latest
+
+services:
+  - docker:dind
+
+build:
+  rules:
+    - if: $CI_COMMIT_TAG =~ /.+/
+      variables:
+        VID: $CI_COMMIT_TAG
+    - when: manual
+      variables:
+        VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
+  stage: build
+  before_script:
+    - apk update
+    - apk add --no-cache git
+  script:
+    - docker build -f Dockerfile -t korap/kalamar:$VID-conv --target kalamar-convert .
+    - docker save korap/kalamar:$VID-conv | xz -T0 -M16G -9 > kalamar-$VID-conv.xz
+  artifacts:
+    paths:
+      - kalamar-$VID-conv.xz
+