From da0942e79414971625350976d790057584eadbfa Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Wed, 25 Sep 2019 21:20:29 +0500 Subject: [PATCH] CI --- .gitlab-ci.yml | 31 +++++++++++++++++++++++++++++++ docker/set_docker_tag.sh | 7 +++++++ 2 files changed, 38 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 docker/set_docker_tag.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..4617214 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,31 @@ +image: docker:dind + +variables: + HOST: 0.0.0.0 + PORT: 2375 + DOCKER_HOST: tcp://docker:2375/ + DOCKER_DRIVER: overlay2 + CONTAINER_NAME: registry.gitlab.com/pztrn/opensaps + GIT_STRATEGY: clone + DOCKER_TLS_CERTDIR: "" + +services: + - docker:dind + +stages: + - build + +before_script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + +build: + stage: build + tags: + - docker + script: + - source docker/set_docker_tag.sh + - docker build -t $CONTAINER_NAME:$DOCKER_TAG . + - docker push $CONTAINER_NAME:$DOCKER_TAG + only: + - tags + - master \ No newline at end of file diff --git a/docker/set_docker_tag.sh b/docker/set_docker_tag.sh new file mode 100644 index 0000000..71222ba --- /dev/null +++ b/docker/set_docker_tag.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [[ $CI_BUILD_REF_NAME == "master" ]]; then + export DOCKER_TAG=latest; +else + export DOCKER_TAG="${CI_BUILD_REF_NAME}"; +fi \ No newline at end of file