-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
136 lines (122 loc) · 4.1 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
variables:
DOCKER_DRIVER: overlay2
#DOMAIN: dapppad.com
GITHUB_REF: $CI_COMMIT_SHA
DH_IMAGE_NAME: $CI_PROJECT_ROOT_NAMESPACE/$CI_PROJECT_NAME
SERVICE: $CI_PROJECT_NAME
REGISTRY: registry.gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
IMAGE_NAME: $REGISTRY:$CI_COMMIT_SHA
IMAGE_NAME_TAG: $REGISTRY:$CI_COMMIT_TAG
WERF_LOG_COLOR_MODE: "on"
WERF_IMAGES_REPO: $CI_REGISTRY_IMAGE
BUILD_BASE_IMAGE: $IMAGE_NAME/buildbase:2
BUILD_IMAGE: corebuild
BUILDNC_IMAGE: corebuildnc
BUILD_DOCKERFILE: build.dockerfile
BUILDNC_DOCKERFILE: buildnc.dockerfile
LEGACY_IMAGE: $IMAGE_NAME:$CI_COMMIT_SHA
LEGACY_DOCKERFILE: legacy.dockerfile
PG_IMAGE: $IMAGE_NAME:pg-$CI_COMMIT_SHA
PGNC_IMAGE: $IMAGE_NAME:pg-$CI_COMMIT_SHA-nc
PG_DOCKERFILE: pg.dockerfile
PGNC_DOCKERFILE: pgnc.dockerfile
DH_IMAGE: tokend/core
DHNC_IMAGE: tokendconto/core
.before_script_template: &before_script_templ
before_script:
- werf version
- docker version
- echo $CI_REGISTRY
- echo $CI_REGISTRY_USER
- echo $CI_REGISTRY_PASSWORD
- echo $WERF_IMAGES_REPO
- echo $WERF_ADD_CUSTOM_TAG_1
stages:
- build-and-publish
#- deploy
- cleanup
Build and Publish:
stage: build-and-publish
tags:
- tokend
services:
- docker:18-dind
image:
name: "registry.gitlab.com/tokend/devops/werf-dind:8588e38f423bc5cc35c68e57e0c0dd57eb920e5d"
entrypoint: [""]
<<: *before_script_templ
script:
- VERSION=$(echo $CI_COMMIT_TAG)
# login to docker registry
- type werf && source $(werf ci-env gitlab --as-file)
- werf build --report-path=images-report.json
- docker pull $(cat images-report.json | jq -r .Images.corepg.DockerImageName)
- docker tag $(cat images-report.json | jq -r .Images.corepg.DockerImageName) $IMAGE_NAME
- docker push $IMAGE_NAME
except: [schedules]
interruptible: true
Build and Publish DH:
stage: build-and-publish
tags:
- tokend
services:
- docker:18-dind
image:
name: "registry.gitlab.com/tokend/devops/werf-dind:8588e38f423bc5cc35c68e57e0c0dd57eb920e5d"
entrypoint: [""]
only:
- /^.+\..+\..+$/
script:
- VERSION=$(test -z $CI_COMMIT_TAG && echo $CI_COMMIT_SHA || echo $CI_COMMIT_TAG)
# login to docker registry
- RELEASE=$CI_COMMIT_REF_NAME
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PWD
- type werf && source $(werf ci-env gitlab --as-file)
- werf build --report-path=images-report.json
- docker pull $(cat images-report.json | jq -r .Images.corepg.DockerImageName)
- docker tag $(cat images-report.json | jq -r .Images.corepg.DockerImageName) $DH_IMAGE:$RELEASE
- docker push $DH_IMAGE:$RELEASE
# Deploy to Staging:
# services:
# - docker:18-dind
# image: dtzar/helm-kubectl:latest
# tags:
# - tokend
# stage: deploy
# script:
# - mkdir ~/.kube/
# - echo ${k8sconfig} | base64 -d > config
# - mv config ~/.kube/
# - helm upgrade -i "webclient" ".helm" --set global.IngressDomain=stage.${DOMAIN} --set "image.repository=${REGISTRY}" --set "image.tag=${CI_COMMIT_SHA}" --create-namespace --namespace $CI_PROJECT_NAME-stage
# interruptible: true
# Deploy to Production:
# services:
# - docker:18-dind
# image: dtzar/helm-kubectl:latest
# tags:
# - tokend
# stage: deploy
# script:
# - mkdir ~/.kube/
# - echo ${k8sconfig} | base64 -d > config
# - mv config ~/.kube/
# - helm upgrade -i "webclient" ".helm" --set global.IngressDomain=${DOMAIN} --set "image.repository=${REGISTRY}" --set "image.tag=${CI_COMMIT_TAG}" --create-namespace --namespace $CI_PROJECT_NAME-prod
# when: manual
# interruptible: true
Cleanup:
stage: cleanup
tags:
- tokend
services:
- docker:18-dind
image:
name: "registry.gitlab.com/tokend/devops/werf-dind:8588e38f423bc5cc35c68e57e0c0dd57eb920e5d"
entrypoint: [""]
<<: *before_script_templ
script:
- type werf && source $(werf ci-env gitlab --as-file)
- docker login -u nobody -p ${WERF_IMAGES_CLEANUP_PASSWORD} ${WERF_IMAGES_REPO}
- werf cleanup
only: [schedules]
interruptible: true