From fc69eedfea403ea9c1c14a8af068aa5e8a69fb5f Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Fri, 6 Sep 2019 13:00:11 +0200
Subject: [PATCH] Add CI script
---
.gitlab-ci.yml | 52 ++++++++++++++++++++++++++++++++++++++++++++++
docker-compose.yml | 2 +-
2 files changed, 53 insertions(+), 1 deletion(-)
create mode 100644 .gitlab-ci.yml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..c80f44f6
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,52 @@
+image: docker:latest
+
+services:
+ - docker:dind
+
+stages:
+ - build
+ - push
+
+before_script:
+ - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+
+Build:
+ script:
+ - docker build --pull -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
+ - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
+ stage: build
+ tags:
+ - docker
+
+Push development:
+ only:
+ - development
+ script:
+ - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
+ - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:development
+ - docker push $CI_REGISTRY_IMAGE:development
+ stage: push
+ tags:
+ - docker
+
+Push latest:
+ only:
+ - master
+ script:
+ - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
+ - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
+ - docker push $CI_REGISTRY_IMAGE:latest
+ stage: push
+ tags:
+ - docker
+
+Push tag:
+ only:
+ - tags
+ script:
+ - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
+ - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+ - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+ stage: push
+ tags:
+ - docker
diff --git a/docker-compose.yml b/docker-compose.yml
index b2888e89..fbe16c00 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -9,7 +9,7 @@ services:
env_file:
- opaque_database_env
- opaque_env
- image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque:latest
+ image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque:development
ports:
- 5000:5000
restart: always