forked from telekom-mms/docker-management-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab-ci.yml
47 lines (43 loc) · 1.3 KB
/
gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# .gitlab-ci.yml
---
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
GIT_DEPTH: 0
GIT_SUBMODULE_STRATEGY: recursive
SERVICE: mms
DMC: ${SERVICE}-mgmt-dmc
DMC_DIR: ${CI_PROJECT_DIR}/docker/
DMC_IMAGE: $CI_REGISTRY_IMAGE/${DMC}
GITHUB_DMC_REF: latest
include:
- local: .gitlab/ci/*
# .gitlab/ci/login.yml
---
.docker_login:
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# .gitlab/ci/dmc.yml
---
include: ${CI_PROJECT_DIR}/.gitlab/ci/login.yml
# build management-container
build-dmc:
services:
- name: docker:dind
alias: docker
image: docker:git
script:
# clone DMC repo from GitHub
- git clone --recursive --branch ${GITHUB_DMC_REF} --depth 1 https://github.com/T-Systems-MMS/docker-management-container ${DMC_DIR}/docker-management-container
# get date for tagging the image
- export DATE=$(date +"%F")
# create Dockerfile with template from DMC repo
- sh ${CI_PROJECT_DIR}/docker/docker-management-container/render.sh ${DMC_DIR}/${DMC}
# build and tag image
- docker build -t ${DMC_IMAGE}:${DATE} ${DMC_DIR}/${DMC}
- docker tag ${DMC_IMAGE}:${DATE} ${DMC_IMAGE}:latest
# push all images
- docker push --all-tags ${DMC_IMAGE}
extends:
- .docker_login