GitLab-CI: add build-docker job with slimming
Change-Id: If2b9d90d28e2637fab7aa6ea525feb446f6e05d4
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f0209f3..137a62d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,6 +18,13 @@
PERL5LIB: ./perl5/lib/perl5
build-and-test:
+ rules:
+ - if: $CI_COMMIT_TAG =~ /.+/
+ variables:
+ VID: $CI_COMMIT_TAG
+ - when: manual
+ variables:
+ VID: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
stage: build
cache:
# Cache is shared between branches, but has a unique cache per job.
@@ -105,3 +112,35 @@
script:
- echo "This is a manual job which doesn't start automatically, and the pipeline can complete without it starting."
- ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $DEPLOY_HOST "cd /opt/korap/derekovecs && git stash && git pull && cpanm --installdeps . && cpanm . && rm -rf _Inline && sudo systemctl restart derekovecs"
+
+build-docker:
+ image: docker:latest
+ services:
+ - docker:dind
+ 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:
+ - env
+ - apk update
+ - apk add --no-cache git
+ script:
+ - ESCAPED_PWD=$(echo $CI_PROJECT_DIR | sed 's/\//\\\//g')
+ - echo $ESCAPED_PWD
+ - sed -i -e "s/RUN rm -rf example-models//" Dockerfile
+ - cat Dockerfile
+ - docker build -f Dockerfile -t idscorpuslinguistics/derekovecs:$VID-large .
+ - 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 --include-path /sbin --include-path /usr/local/share/perl5 --env MOJO_CONFIG=/derekovecs/example-models/example-docker.conf --http-probe=true --tag idscorpuslinguistics/derekovecs:tmp idscorpuslinguistics/derekovecs:$VID-large
+ - docker build -f Dockerfile.remove-example-data --tag idscorpuslinguistics/derekovecs:latest --tag idscorpuslinguistics/derekovecs:$VID .
+ - docker save idscorpuslinguistics/derekovecs:$VID | xz -T0 -M16G -9 > derekovecs.tar.xz
+ artifacts:
+ paths:
+ - derekovecs.tar.xz