GitLab-CI: Add version tag and manual Docker Hub push job
Change-Id: Ieb266f9e286363ba5f233f96258015f4e5fabb72
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7442d13..b95a146 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,15 +1,12 @@
-# gitlab ci pipeline to build kalamar docker container
-# automatically triggered on tag pushs or run manually
-#
-# Download latest container from artifacts and import it:
-#
-# curl -Ls 'https://gitlab.ids-mannheim.de/KorAP/Kalamar/-/jobs/artifacts/master/raw/kalamar.tar.xz?job=build-docker' | docker load
-
image: docker:latest
services:
- docker:dind
+stages:
+ - build
+ - deploy
+
build-docker:
rules:
- if: $CI_COMMIT_TAG =~ /.+/
@@ -24,12 +21,33 @@
- apk add --no-cache git
script:
- docker build -f Dockerfile -t korap/kalamar:$VID-large --target kalamar .
-# - wget https://github.com/slimtoolkit/slim/releases/latest/download/dist_linux.tar.gz
-# - tar zxf dist_linux.tar.gz
-# - export PATH=$(pwd)/dist_linux:$PATH
- - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build --http-probe=true --exec="perl Makefile.PL && make test && unzip -v" --include-workdir=true --include-path=/usr/local/share/perl5/site_perl/KorAP/ --tag korap/kalamar:$VID --tag korap/kalamar:latest korap/kalamar:$VID-large
- - docker save korap/kalamar:$VID | xz -T0 -M16G -9 > kalamar.tar.xz
+ - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build --http-probe=true --exec="perl Makefile.PL && make test && unzip -v" --include-workdir=true --include-path=/usr/local/share/perl5/site_perl/KorAP/ --include-path=/usr/local/share/perl5/site_perl/Mojolicious/ --include-path=/usr/local/share/perl5/site_perl/Mojo/ --tag korap/kalamar:$VID --tag korap/kalamar:latest korap/kalamar:$VID-large
+ - ARTIFACT=kalamar-${VID}.tar.xz
+ - docker save korap/kalamar:$VID | xz -T0 -M16G -9 > "$ARTIFACT"
artifacts:
paths:
- - kalamar.tar.xz
+ - kalamar-*.tar.xz
+
+push-dockerhub:
+ stage: deploy
+ needs:
+ - job: build-docker
+ artifacts: true
+ dependencies:
+ - build-docker
+ rules:
+ - if: $CI_COMMIT_TAG =~ /^v.+/
+ when: manual
+ - when: never
+ script:
+ - apk update
+ - apk add --no-cache xz
+ - echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
+ - ARTIFACT=kalamar-${CI_COMMIT_TAG}.tar.xz
+ - xz -d -c "$ARTIFACT" | docker load
+ - docker tag korap/kalamar:$CI_COMMIT_TAG korap/kalamar:latest
+ - docker tag korap/kalamar:$CI_COMMIT_TAG korap/kalamar:latest-conv
+ - docker push korap/kalamar:$CI_COMMIT_TAG
+ - docker push korap/kalamar:latest
+ - docker push korap/kalamar:latest-conv