-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
51 lines (44 loc) · 1.76 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
48
49
50
image: docker:git
services:
# Hack to make the dns work on the internal network
- name: docker:dind
entrypoint: ["dockerd-entrypoint.sh", "--dns", "172.31.1.1"]
stages:
- build
- release
variables:
# REGISTRY_ENDPOINT=${CI_REGISTRY_IMAGE} # Use this when deployed on gitlab.com
REGISTRY_ENDPOINT: registry-special.tenforce.com
IMAGE_NAME: ${REGISTRY_ENDPOINT}/special/demonstrator-consent-management-frontend
before_script:
# - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} registry.gitlab.com # Use this when deployed on gitlab.com
# Docker login could be replaced by setting a DOCKER_AUTH_CONFIG secret variable (see https://docs.gitlab.com/ce/ci/docker/using_docker_images.html#define-an-image-from-a-private-container-registry)
- docker login -u ${REGISTRY_USERNAME} -p ${REGISTRY_PASSWORD} ${REGISTRY_ENDPOINT} # If we keep using the azure registry, improve the authentication
build-dev:
stage: build
script:
- docker pull ${IMAGE_NAME}:latest
- docker build --cache-from ${IMAGE_NAME}:latest -t ${IMAGE_NAME}:${CI_COMMIT_REF_NAME} .
- docker push ${IMAGE_NAME}:${CI_COMMIT_REF_NAME}
except:
- master
- tags
build-prod:
stage: build
script:
- docker pull ${IMAGE_NAME}:latest
- docker build --cache-from ${IMAGE_NAME}:latest -t ${IMAGE_NAME}:${CI_COMMIT_REF_NAME} --build-arg env=production .
- docker push ${IMAGE_NAME}:${CI_COMMIT_REF_NAME}
only:
- master
- tags
release-prod:
stage: release
script:
- docker pull ${IMAGE_NAME}:${CI_COMMIT_REF_NAME}
- target_image=${IMAGE_NAME}:$([ "${CI_COMMIT_REF_NAME}" = "master" ] && echo "latest" || echo "${CI_COMMIT_TAG}")
- docker tag ${IMAGE_NAME}:${CI_COMMIT_REF_NAME} ${target_image}
- docker push ${target_image}
only:
- master
- tags