-
Notifications
You must be signed in to change notification settings - Fork 17
/
.gitlab-ci.yml
150 lines (137 loc) · 6.25 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
stages:
- docker-dev
- deploy-dev
#- deploy-sec
- deploy-new-prd
- deploy-test
#- deploy-staging
- docker-prd
- deploy-prd
variables:
IMAGE_AUTH_SERVER_ADMIN_DEV: $CI_ALI_REGISTRY_DOMAIN/masastack/masa-auth-service-admin:dev-$CI_PIPELINE_ID
IMAGE_AUTH_WEB_ADMIN_SERVER_DEV: $CI_ALI_REGISTRY_DOMAIN/masastack/masa-auth-web-admin-server:dev-$CI_PIPELINE_ID
IMAGE_AUTH_WEB_ADMIN_SSO_DEV: $CI_ALI_REGISTRY_DOMAIN/masastack/masa-auth-web-sso:dev-$CI_PIPELINE_ID
IMAGE_AUTH_SERVER_ADMIN: $CI_ALI_REGISTRY_DOMAIN/masastack/masa-auth-service-admin:$CI_COMMIT_TAG
IMAGE_AUTH_WEB_ADMIN_SERVER: $CI_ALI_REGISTRY_DOMAIN/masastack/masa-auth-web-admin-server:$CI_COMMIT_TAG
IMAGE_AUTH_WEB_ADMIN_SSO: $CI_ALI_REGISTRY_DOMAIN/masastack/masa-auth-web-sso:$CI_COMMIT_TAG
DOCKER_AUTH_ADMIN_SERVER_PATH: ./src/Services/Masa.Auth.Service.Admin/Dockerfile
DOCKER_AUTH_ADMIN_WEB_PATH: ./src/Web/Masa.Auth.Web.Admin.Server/Dockerfile
DOCKER_AUTH_ADMIN_WEB_SSO_PATH: ./src/Web/Masa.Auth.Web.Sso/Dockerfile
NAMESPACE_DEV: masastack-dev
NAMESPACE_TEST: masastack-test
NAMESPACE_STAGING: masastack-staging
NAMESPACE_PRD: masastack
NAMESPACE_SEC: masa-to-sec
docker-dev:
stage: docker-dev
tags:
- linux-shell
before_script:
- docker login -u $CI_ALI_REGISTRY_USER -p $CI_ALI_REGISTRY_PASSWD $CI_ALI_REGISTRY_DOMAIN
only:
- main
script:
- docker build -f $DOCKER_AUTH_ADMIN_SERVER_PATH -t $IMAGE_AUTH_SERVER_ADMIN_DEV .
- docker push $IMAGE_AUTH_SERVER_ADMIN_DEV
- docker build -f $DOCKER_AUTH_ADMIN_WEB_PATH -t $IMAGE_AUTH_WEB_ADMIN_SERVER_DEV .
- docker push $IMAGE_AUTH_WEB_ADMIN_SERVER_DEV
- docker build -f $DOCKER_AUTH_ADMIN_WEB_SSO_PATH -t $IMAGE_AUTH_WEB_ADMIN_SSO_DEV .
- docker push $IMAGE_AUTH_WEB_ADMIN_SSO_DEV
after_script:
- docker rmi $IMAGE_AUTH_SERVER_ADMIN_DEV
- docker rmi $IMAGE_AUTH_WEB_ADMIN_SERVER_DEV
- docker rmi $IMAGE_AUTH_WEB_ADMIN_SSO_DEV
deploy-dev:
stage: deploy-dev
image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
only:
- main
script:
- echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
- echo $CI_PIPELINE_ID
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_DEV
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_DEV
- kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_DEV
retry: 2
deploy-sec:
stage: deploy-dev
image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
only:
- main
script:
- echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
- echo $CI_PIPELINE_ID
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_SEC
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_SEC
- kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_SEC
retry: 2
deploy-test:
stage: deploy-test
image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
only:
- main
script:
- echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
- echo $CI_PIPELINE_ID
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_TEST
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_TEST
- kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_TEST
retry: 2
when: manual
deploy-new-prd:
stage: deploy-new-prd
image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
only:
- main
script:
- echo $KUBE_CONFIG_LSD_PRD_YDY | base64 -d > ./config
- echo $CI_COMMIT_ID
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_PRD
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_PRD
- kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_PRD
retry: 2
when: manual
# deploy-staging:
# stage: deploy-staging
# image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
# only:
# - main
# script:
# - echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
# - echo $CI_PIPELINE_ID
# - kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_STAGING
# - kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_STAGING
# - kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_STAGING
# retry: 2
# when: manual
docker-prd:
stage: docker-prd
tags:
- linux-shell
image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
only:
- tags
script:
- docker build -f $DOCKER_AUTH_ADMIN_SERVER_PATH -t $IMAGE_AUTH_SERVER_ADMIN .
- docker push $IMAGE_AUTH_SERVER_ADMIN
- docker build -f $DOCKER_AUTH_ADMIN_WEB_PATH -t $IMAGE_AUTH_WEB_ADMIN_SERVER .
- docker push $IMAGE_AUTH_WEB_ADMIN_SERVER
- docker build -f $DOCKER_AUTH_ADMIN_WEB_SSO_PATH -t $IMAGE_AUTH_WEB_ADMIN_SSO .
- docker push $IMAGE_AUTH_WEB_ADMIN_SSO
after_script:
- docker rmi $IMAGE_AUTH_SERVER_ADMIN
- docker rmi $IMAGE_AUTH_WEB_ADMIN_SERVER
- docker rmi $IMAGE_AUTH_WEB_ADMIN_SSO
deploy-prd:
stage: deploy-prd
image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
only:
- tags
script:
- echo $KUBE_CONFIG_LSD_PRD_YDY | base64 -d > ./config
- echo $CI_COMMIT_TAG
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER -n $NAMESPACE_PRD
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN -n $NAMESPACE_PRD
- kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO -n $NAMESPACE_PRD
retry: 2
when: manual