-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
59 lines (52 loc) · 1.59 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
51
52
53
54
55
56
57
58
59
image: docker:git
services:
- docker:dind
stages:
- build
- test
- release
variables:
REGISTRY_ENDPOINT: registry-special.tenforce.com
REGISTRY_IMAGE: registry-special.tenforce.com/special/consent-management-backend-mongo
CONTAINER_TEST_IMAGE: ${REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-test
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}
test:
stage: test
image: ${CONTAINER_TEST_IMAGE}
before_script:
- echo "Disable global before script"
variables:
GIT_STRATEGY: none
script:
- ls
release:
stage: release
script:
- docker pull ${CONTAINER_RELEASE_IMAGE}
- target_image=$([ "${CI_COMMIT_REF_NAME}" = "master" ] && echo "${CONTAINER_RELEASE_IMAGE}" || echo "${CONTAINER_TAG_IMAGE}")
- docker build --build-arg NODE_ENV=production --cache-from ${CONTAINER_RELEASE_IMAGE} -t ${target_image} .
- docker push ${target_image}
only:
- master
- tags
publish-vienna:
stage: release
variables:
GIT_STRATEGY: clone
script:
- eval $(ssh-agent -s)
- echo "${SSH_PRIVATE_KEY}" | ssh-add /dev/stdin
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- git push ${VIENNA_REMOTE} master
only:
- master