-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
36 lines (30 loc) · 1.02 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
image: docker:git
services:
- docker:dind
stages:
- build
- release
variables:
REGISTRY_ENDPOINT: registry-special.tenforce.com
REGISTRY_IMAGE: registry-special.tenforce.com/special/demonstrator-dispatcher
CONTAINER_TEST_IMAGE: ${REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
CONTAINER_RELEASE_IMAGE: ${REGISTRY_IMAGE}:latest
CONTAINER_TAG_IMAGE: ${REGISTRY_IMAGE}:${CI_COMMIT_TAG}
before_script:
- docker login -u ${REGISTRY_USERNAME} -p ${REGISTRY_PASSWORD} ${REGISTRY_ENDPOINT}
build:
stage: build
script:
- docker pull "${CONTAINER_RELEASE_IMAGE}"
- docker build --cache-from "${CONTAINER_RELEASE_IMAGE}" -t ${CONTAINER_TEST_IMAGE} .
- docker push ${CONTAINER_TEST_IMAGE}
release:
stage: release
script:
- docker pull ${CONTAINER_TEST_IMAGE}
- target_image=$([ "${CI_COMMIT_REF_NAME}" = "master" ] && echo "${CONTAINER_RELEASE_IMAGE}" || echo "${CONTAINER_TAG_IMAGE}")
- docker tag ${CONTAINER_TEST_IMAGE} "${target_image}"
- docker push "${target_image}"
only:
- master
- tags