@xfe-repo/mini-app 1.6.5 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -2
- package/babel.config.js +2 -12
- package/config/dev.ts +1 -25
- package/config/index.ts +52 -21
- package/config/prod.ts +1 -7
- package/deploy/.drone.yml +153 -160
- package/deploy/Dockerfile +4 -0
- package/deploy/helm/Chart.yaml +1 -1
- package/deploy/helm/templates/deployment.yaml +60 -22
- package/deploy/helm/templates/pvc.yaml +17 -0
- package/deploy/helm/templates/template.yaml +16 -0
- package/deploy/helm/templates/virtualService.yaml +13 -8
- package/deploy/helm/values.yaml +40 -7
- package/dist/chunk-4JD7C4FF.mjs +22 -164
- package/dist/chunk-MLSNG3O7.mjs +67 -336
- package/dist/chunk-MSNDQMQN.mjs +153 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/cli.js +504 -681
- package/dist/cli.mjs +55 -348
- package/dist/config.d.mts +6 -5
- package/dist/config.d.ts +6 -5
- package/dist/config.js +168 -298
- package/dist/config.mjs +11 -2
- package/dist/preview.js +87 -401
- package/dist/preview.mjs +11 -2
- package/dist/upload.js +83 -349
- package/dist/upload.mjs +7 -2
- package/dist/workspace-7FXUJJOQ.mjs +220 -0
- package/package.json +19 -18
- package/dist/chunk-75BJNL7E.mjs +0 -239
package/deploy/.drone.yml
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
# 通用 依赖安装部分
|
|
1
|
+
# 此文件为@xfe-repo中的mini-app项目的部署文件 此处为副本 请勿修改
|
|
3
2
|
kind: pipeline
|
|
4
3
|
type: kubernetes
|
|
5
|
-
name:
|
|
4
|
+
name: deploy
|
|
6
5
|
|
|
7
6
|
metadata:
|
|
8
7
|
namespace: cicd
|
|
@@ -12,131 +11,107 @@ trigger:
|
|
|
12
11
|
- custom
|
|
13
12
|
- tag
|
|
14
13
|
|
|
14
|
+
resources:
|
|
15
|
+
requests:
|
|
16
|
+
memory: 4096MiB
|
|
17
|
+
|
|
15
18
|
steps:
|
|
16
19
|
- name: install
|
|
17
20
|
pull: if-not-exists
|
|
18
|
-
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-
|
|
19
|
-
volumes:
|
|
20
|
-
- name: node-modules
|
|
21
|
-
path: /drone/src/node_modules
|
|
21
|
+
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-cicd:26.13.0
|
|
22
22
|
commands:
|
|
23
23
|
- pnpm config set registry https://registry.npmmirror.com
|
|
24
24
|
- pnpm i
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
- name: node-modules
|
|
28
|
-
host:
|
|
29
|
-
path: /var/lib/node/${DRONE_REPO_NAME}-node-modules-pnpm
|
|
30
|
-
|
|
31
|
-
image_pull_secrets:
|
|
32
|
-
- docker-key
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
# 小程序构建部分
|
|
36
|
-
kind: pipeline
|
|
37
|
-
type: kubernetes
|
|
38
|
-
name: deploy-mini
|
|
39
|
-
|
|
40
|
-
depends_on:
|
|
41
|
-
- install
|
|
42
|
-
|
|
43
|
-
metadata:
|
|
44
|
-
namespace: cicd
|
|
45
|
-
|
|
46
|
-
trigger:
|
|
47
|
-
event:
|
|
48
|
-
- custom
|
|
49
|
-
- tag
|
|
50
|
-
|
|
51
|
-
steps:
|
|
52
|
-
- name: build
|
|
26
|
+
- name: configure
|
|
53
27
|
pull: if-not-exists
|
|
54
|
-
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-
|
|
55
|
-
volumes:
|
|
56
|
-
- name: node-modules
|
|
57
|
-
path: /drone/src/node_modules
|
|
28
|
+
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-cicd:26.13.0
|
|
58
29
|
commands:
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
- pnpm build --type weapp
|
|
30
|
+
- pnpm exec xfe-mini config
|
|
31
|
+
- git diff --exit-code -- deploy/.drone.yml
|
|
62
32
|
|
|
63
|
-
- name:
|
|
33
|
+
- name: build-mini
|
|
64
34
|
pull: if-not-exists
|
|
65
|
-
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-
|
|
66
|
-
volumes:
|
|
67
|
-
- name: node-modules
|
|
68
|
-
path: /drone/src/node_modules
|
|
35
|
+
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-cicd:26.13.0
|
|
69
36
|
commands:
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
- pnpm preview -d "$API_ENV $DRONE_COMMIT_MESSAGE"
|
|
73
|
-
- echo '二维码将在2小时内过期 可在微信小程序助手中 找到此版本'
|
|
37
|
+
- export API_ENV=$(bash deploy/env.sh)
|
|
38
|
+
- pnpm run build:ci
|
|
74
39
|
when:
|
|
40
|
+
event:
|
|
41
|
+
exclude: <<EXCLUDE_EVENTS_weapp>>
|
|
42
|
+
|
|
43
|
+
- name: preview-test
|
|
44
|
+
pull: if-not-exists
|
|
45
|
+
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-cicd:26.13.0
|
|
46
|
+
environment:
|
|
47
|
+
MINI_PRIVATE_KEY:
|
|
48
|
+
from_secret: mini-private-key
|
|
49
|
+
commands: &previewMini
|
|
50
|
+
- export API_ENV=$(bash deploy/env.sh)
|
|
51
|
+
- set +x
|
|
52
|
+
- test -n "$MINI_PRIVATE_KEY"
|
|
53
|
+
- umask 077
|
|
54
|
+
- printf '%s' "$MINI_PRIVATE_KEY" > private.key
|
|
55
|
+
- trap 'rm -f private.key' EXIT
|
|
56
|
+
- pnpm exec xfe-mini preview --desc "$API_ENV $DRONE_COMMIT_MESSAGE"
|
|
57
|
+
when:
|
|
58
|
+
event:
|
|
59
|
+
include: [custom]
|
|
60
|
+
exclude: <<EXCLUDE_EVENTS_weapp_test>>
|
|
61
|
+
|
|
62
|
+
- name: preview-stage
|
|
63
|
+
pull: if-not-exists
|
|
64
|
+
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-cicd:26.13.0
|
|
65
|
+
environment:
|
|
66
|
+
MINI_PRIVATE_KEY:
|
|
67
|
+
from_secret: mini-private-key
|
|
68
|
+
commands: *previewMini
|
|
69
|
+
when:
|
|
70
|
+
event:
|
|
71
|
+
exclude: <<EXCLUDE_EVENTS_weapp_stage>>
|
|
75
72
|
ref:
|
|
76
|
-
|
|
77
|
-
- refs/tags/release-*
|
|
73
|
+
include: [refs/tags/stage-*]
|
|
78
74
|
|
|
79
|
-
- name: upload
|
|
75
|
+
- name: upload-mini
|
|
80
76
|
pull: if-not-exists
|
|
81
|
-
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-cicd:26.13.0
|
|
78
|
+
environment:
|
|
79
|
+
MINI_PRIVATE_KEY:
|
|
80
|
+
from_secret: mini-private-key
|
|
85
81
|
commands:
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
82
|
+
- export API_ENV=$(bash deploy/env.sh)
|
|
83
|
+
- set +x
|
|
84
|
+
- test -n "$MINI_PRIVATE_KEY"
|
|
85
|
+
- umask 077
|
|
86
|
+
- printf '%s' "$MINI_PRIVATE_KEY" > private.key
|
|
87
|
+
- trap 'rm -f private.key' EXIT
|
|
88
|
+
- pnpm exec xfe-mini upload --desc "$DRONE_COMMIT_MESSAGE" --version "$${DRONE_TAG#release-}"
|
|
90
89
|
when:
|
|
90
|
+
event:
|
|
91
|
+
exclude: <<EXCLUDE_EVENTS_weapp_prod>>
|
|
91
92
|
ref:
|
|
92
|
-
include:
|
|
93
|
-
- refs/tags/release-*
|
|
94
|
-
|
|
95
|
-
volumes:
|
|
96
|
-
- name: node-modules
|
|
97
|
-
host:
|
|
98
|
-
path: /var/lib/node/${DRONE_REPO_NAME}-node-modules-pnpm
|
|
93
|
+
include: [refs/tags/release-*]
|
|
99
94
|
|
|
100
|
-
|
|
101
|
-
- docker-key
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
# h5构建部分
|
|
105
|
-
kind: pipeline
|
|
106
|
-
type: kubernetes
|
|
107
|
-
name: deploy-h5
|
|
108
|
-
|
|
109
|
-
depends_on:
|
|
110
|
-
- install
|
|
111
|
-
|
|
112
|
-
metadata:
|
|
113
|
-
namespace: cicd
|
|
114
|
-
|
|
115
|
-
trigger:
|
|
116
|
-
event:
|
|
117
|
-
- custom
|
|
118
|
-
- tag
|
|
119
|
-
|
|
120
|
-
steps:
|
|
121
|
-
- name: build
|
|
95
|
+
- name: build-h5
|
|
122
96
|
pull: if-not-exists
|
|
123
|
-
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-
|
|
97
|
+
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/node-cicd:26.13.0
|
|
124
98
|
resources:
|
|
125
99
|
limits:
|
|
126
|
-
|
|
127
|
-
memory: 8000MiB
|
|
128
|
-
volumes:
|
|
129
|
-
- name: node-modules
|
|
130
|
-
path: /drone/src/node_modules
|
|
100
|
+
memory: 8192MiB
|
|
131
101
|
commands:
|
|
132
|
-
-
|
|
133
|
-
- export
|
|
134
|
-
-
|
|
135
|
-
-
|
|
102
|
+
- export API_ENV=$(bash deploy/env.sh)
|
|
103
|
+
- export NODE_OPTIONS="--max-old-space-size=8192"
|
|
104
|
+
- export REACT_APP_RELEASE="$DRONE_REPO_NAME@$DRONE_COMMIT_SHA"
|
|
105
|
+
- if [ -n "$DRONE_TAG" ]; then export REACT_APP_RELEASE="$DRONE_REPO_NAME@$DRONE_TAG"; fi
|
|
106
|
+
- printf '%s' "$REACT_APP_RELEASE" > deploy/static/release
|
|
107
|
+
- pnpm run build:ci:h5
|
|
108
|
+
when:
|
|
109
|
+
event:
|
|
110
|
+
exclude: <<EXCLUDE_EVENTS_h5>>
|
|
136
111
|
|
|
137
112
|
- name: image-build
|
|
138
113
|
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/image-common/kaniko:latest
|
|
139
|
-
pull:
|
|
114
|
+
pull: if-not-exists
|
|
140
115
|
settings:
|
|
141
116
|
registry: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com
|
|
142
117
|
username:
|
|
@@ -149,68 +124,89 @@ steps:
|
|
|
149
124
|
tags:
|
|
150
125
|
- ${CI_COMMIT_SHA}
|
|
151
126
|
- latest
|
|
127
|
+
when:
|
|
128
|
+
event:
|
|
129
|
+
exclude: <<EXCLUDE_EVENTS_h5>>
|
|
152
130
|
|
|
153
131
|
- name: pre-deploy
|
|
154
132
|
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/deploy-helm:latest
|
|
155
133
|
environment:
|
|
156
|
-
|
|
157
|
-
from_secret:
|
|
158
|
-
INFRA_K8S_CONFIG:
|
|
159
|
-
from_secret: infra-k8s-config
|
|
134
|
+
K8S_CONFIG:
|
|
135
|
+
from_secret: target-k8s-config
|
|
160
136
|
commands:
|
|
161
|
-
#
|
|
162
|
-
-
|
|
163
|
-
|
|
164
|
-
-
|
|
137
|
+
# 集群凭据通过生成入口选定,运行流程不再注入其他集群的凭据。
|
|
138
|
+
- set +x
|
|
139
|
+
- test -n "$MINI_PRIVATE_KEY"
|
|
140
|
+
- umask 077
|
|
141
|
+
- printf '%s' "$K8S_CONFIG" > kube_config
|
|
165
142
|
# 将环境类型写入values.yaml
|
|
166
|
-
- appName
|
|
143
|
+
- appName=$(printf '%s' "$DRONE_REPO" | tr '/' '-')
|
|
167
144
|
- sed -i "s/<<APP_NAME>>/$appName/g" deploy/helm/values.yaml
|
|
168
145
|
- sed -i "s/<<CI_COMMIT_SHA>>/$CI_COMMIT_SHA/g" deploy/helm/values.yaml
|
|
169
146
|
- sed -i "s/<<TAG_CONTENT>>/$DRONE_TAG/g" deploy/helm/values.yaml
|
|
170
|
-
#
|
|
171
|
-
- cat deploy/helm/values.yaml
|
|
147
|
+
# 展示非敏感部署配置
|
|
148
|
+
- cat deploy/helm/values.yaml
|
|
149
|
+
when:
|
|
150
|
+
event:
|
|
151
|
+
exclude: <<EXCLUDE_EVENTS_deploy>>
|
|
172
152
|
|
|
173
153
|
- name: deploy-to-test
|
|
174
154
|
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/deploy-helm:latest
|
|
155
|
+
environment:
|
|
156
|
+
DEPLOY_ENV: test
|
|
175
157
|
commands:
|
|
176
|
-
-
|
|
177
|
-
- cp deploy/helm/values.yaml
|
|
178
|
-
- sed -i "s/<<ENV_TYPE>>/test/g"
|
|
179
|
-
- sed -i "s/<<APP_SUFFIX>>/-$HOST_PREFIX/g"
|
|
180
|
-
- sed -i "s/<<HOST_PREFIX>>/$HOST_PREFIX/g"
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
-
|
|
184
|
-
-
|
|
185
|
-
- helm upgrade --install "$chartName" deploy/helm -f deploy/helm/values.test.yaml --namespace deployment-test --create-namespace --history-max 5
|
|
158
|
+
- VALUES_FILE=deploy/helm/values.test.yaml
|
|
159
|
+
- cp deploy/helm/values.yaml "$VALUES_FILE"
|
|
160
|
+
- sed -i "s/<<ENV_TYPE>>/test/g" "$VALUES_FILE"
|
|
161
|
+
- sed -i "s/<<APP_SUFFIX>>/-$HOST_PREFIX/g" "$VALUES_FILE"
|
|
162
|
+
- sed -i "s/<<HOST_PREFIX>>/$HOST_PREFIX/g" "$VALUES_FILE"
|
|
163
|
+
- &readNamespace namespace=$(awk '$1 == "namespace:" { gsub(/[\047\042]/, "", $2); print $2 }' deploy/helm/values.yaml)
|
|
164
|
+
- test -n "$namespace" || namespace=deployment-test
|
|
165
|
+
- chartName="$(printf '%s' "$DRONE_REPO" | tr '/' '-')-$HOST_PREFIX"
|
|
166
|
+
- &deployHelm helm upgrade --install "$chartName" deploy/helm --values "$VALUES_FILE" --namespace "$namespace" --create-namespace --kubeconfig=kube_config --history-max 5 --atomic --wait --timeout 5m
|
|
186
167
|
when:
|
|
187
168
|
event:
|
|
188
|
-
|
|
169
|
+
include: [custom]
|
|
170
|
+
exclude: <<EXCLUDE_EVENTS_test>>
|
|
189
171
|
|
|
190
172
|
- name: deploy-to-stage
|
|
191
173
|
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/deploy-helm:latest
|
|
174
|
+
environment:
|
|
175
|
+
DEPLOY_ENV: stage
|
|
192
176
|
commands:
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
- sed -i "s/<<
|
|
196
|
-
- sed -i "s/<<
|
|
197
|
-
-
|
|
198
|
-
-
|
|
177
|
+
- VALUES_FILE=deploy/helm/values.stage.yaml
|
|
178
|
+
- cp deploy/helm/values.yaml "$VALUES_FILE"
|
|
179
|
+
- sed -i "s/<<ENV_TYPE>>/stage/g" "$VALUES_FILE"
|
|
180
|
+
- sed -i "s/<<APP_SUFFIX>>//g" "$VALUES_FILE"
|
|
181
|
+
- sed -i "s/<<HOST_PREFIX>>//g" "$VALUES_FILE"
|
|
182
|
+
- *readNamespace
|
|
183
|
+
- test -n "$namespace" || namespace=deployment-stage
|
|
184
|
+
- chartName="$(printf '%s' "$DRONE_REPO" | tr '/' '-')-stage"
|
|
185
|
+
- *deployHelm
|
|
199
186
|
when:
|
|
187
|
+
event:
|
|
188
|
+
exclude: <<EXCLUDE_EVENTS_stage>>
|
|
200
189
|
ref:
|
|
201
190
|
include:
|
|
202
191
|
- refs/tags/stage-*
|
|
203
192
|
|
|
204
193
|
- name: deploy-to-prod
|
|
205
194
|
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/deploy-helm:latest
|
|
195
|
+
environment:
|
|
196
|
+
DEPLOY_ENV: prod
|
|
206
197
|
commands:
|
|
207
|
-
-
|
|
208
|
-
-
|
|
209
|
-
- sed -i "s/<<
|
|
210
|
-
- sed -i "s/<<
|
|
211
|
-
-
|
|
212
|
-
-
|
|
198
|
+
- VALUES_FILE=deploy/helm/values.prod.yaml
|
|
199
|
+
- cp deploy/helm/values.yaml "$VALUES_FILE"
|
|
200
|
+
- sed -i "s/<<ENV_TYPE>>/prod/g" "$VALUES_FILE"
|
|
201
|
+
- sed -i "s/<<APP_SUFFIX>>//g" "$VALUES_FILE"
|
|
202
|
+
- sed -i "s/<<HOST_PREFIX>>//g" "$VALUES_FILE"
|
|
203
|
+
- *readNamespace
|
|
204
|
+
- test -n "$namespace" || namespace=deployment-prod
|
|
205
|
+
- chartName="$(printf '%s' "$DRONE_REPO" | tr '/' '-')"
|
|
206
|
+
- *deployHelm
|
|
213
207
|
when:
|
|
208
|
+
event:
|
|
209
|
+
exclude: <<EXCLUDE_EVENTS_prod>>
|
|
214
210
|
ref:
|
|
215
211
|
include:
|
|
216
212
|
- refs/tags/release-*
|
|
@@ -218,63 +214,60 @@ steps:
|
|
|
218
214
|
- name: deploy-to-stable
|
|
219
215
|
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/deploy-helm:latest
|
|
220
216
|
failure: ignore
|
|
217
|
+
environment:
|
|
218
|
+
DEPLOY_ENV: stable
|
|
221
219
|
commands:
|
|
222
|
-
-
|
|
223
|
-
-
|
|
224
|
-
- sed -i "s/<<
|
|
225
|
-
- sed -i "s/<<
|
|
226
|
-
-
|
|
227
|
-
-
|
|
220
|
+
- VALUES_FILE=deploy/helm/values.stable.yaml
|
|
221
|
+
- cp deploy/helm/values.yaml "$VALUES_FILE"
|
|
222
|
+
- sed -i "s/<<ENV_TYPE>>/test/g" "$VALUES_FILE"
|
|
223
|
+
- sed -i "s/<<APP_SUFFIX>>/-stable/g" "$VALUES_FILE"
|
|
224
|
+
- sed -i "s/<<HOST_PREFIX>>/*/g" "$VALUES_FILE"
|
|
225
|
+
- *readNamespace
|
|
226
|
+
- test -n "$namespace" || namespace=deployment-test
|
|
227
|
+
- chartName="$(printf '%s' "$DRONE_REPO" | tr '/' '-')-stable"
|
|
228
|
+
- *deployHelm
|
|
228
229
|
when:
|
|
230
|
+
event:
|
|
231
|
+
exclude: <<EXCLUDE_EVENTS_stable>>
|
|
229
232
|
ref:
|
|
230
233
|
include:
|
|
231
234
|
- refs/tags/release-*
|
|
232
235
|
|
|
233
236
|
- name: push-helm-chart
|
|
237
|
+
failure: ignore
|
|
234
238
|
image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/deploy-helm:latest
|
|
235
239
|
environment:
|
|
240
|
+
DEPLOY_ENV: prod
|
|
236
241
|
USERNAME:
|
|
237
242
|
from_secret: username
|
|
238
243
|
PASSWORD:
|
|
239
244
|
from_secret: password
|
|
240
245
|
commands:
|
|
241
|
-
- chartName="$
|
|
246
|
+
- chartName="$(printf '%s' "$DRONE_REPO" | tr '/' '-')"
|
|
242
247
|
- chartVersion="0.0.0-$DRONE_TAG"
|
|
243
248
|
- cp deploy/helm/values.prod.yaml deploy/helm/values.yaml
|
|
244
|
-
- sed -i "s
|
|
249
|
+
- 'sed -i "s/^name:.*/name: $chartName/" deploy/helm/Chart.yaml'
|
|
245
250
|
- helm package deploy/helm --version "$chartVersion"
|
|
246
251
|
- set +x
|
|
247
252
|
- printf '%s' "$PASSWORD" | helm registry login xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com --username "$USERNAME" --password-stdin
|
|
248
253
|
- helm push "$chartName-$chartVersion.tgz" oci://xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image
|
|
249
254
|
- >-
|
|
250
|
-
curl -i --fail-with-body
|
|
251
|
-
https://deploy.eshetang.com/deploy.v1.DeployExternalService/UpdateGitOpsChartVersion
|
|
252
|
-
-H 'Content-Type: application/json'
|
|
253
|
-
-d "{\"service\":\"$${chartName}\",\"chartVersion\":\"$${chartVersion}\"}"
|
|
255
|
+
curl -i --fail-with-body --connect-timeout 10 --max-time 60 https://deploy.eshetang.com/deploy.v1.DeployExternalService/UpdateGitOpsChartVersion -H 'Content-Type: application/json' -d "{\"service\":\"$chartName\",\"chartVersion\":\"$chartVersion\"}"
|
|
254
256
|
when:
|
|
257
|
+
event:
|
|
258
|
+
exclude: <<EXCLUDE_EVENTS_push_helm_chart>>
|
|
255
259
|
ref:
|
|
256
260
|
include:
|
|
257
261
|
- refs/tags/release-*
|
|
258
262
|
|
|
259
|
-
volumes:
|
|
260
|
-
- name: node-modules
|
|
261
|
-
host:
|
|
262
|
-
path: /var/lib/node/${DRONE_REPO_NAME}-node-modules-pnpm
|
|
263
|
-
|
|
264
263
|
image_pull_secrets:
|
|
265
264
|
- docker-key
|
|
266
265
|
|
|
267
266
|
---
|
|
268
267
|
kind: secret
|
|
269
|
-
name:
|
|
270
|
-
get:
|
|
271
|
-
path: saas-k8s-config
|
|
272
|
-
name: config
|
|
273
|
-
---
|
|
274
|
-
kind: secret
|
|
275
|
-
name: infra-k8s-config
|
|
268
|
+
name: target-k8s-config
|
|
276
269
|
get:
|
|
277
|
-
path:
|
|
270
|
+
path: <<TARGET_K8S>>-k8s-config
|
|
278
271
|
name: config
|
|
279
272
|
---
|
|
280
273
|
kind: secret
|
package/deploy/Dockerfile
CHANGED
package/deploy/helm/Chart.yaml
CHANGED
|
@@ -7,11 +7,15 @@ metadata:
|
|
|
7
7
|
kubernetes.io/change-cause: {{ or $.Values.tagContent $.Values.commitSHA }}
|
|
8
8
|
spec:
|
|
9
9
|
strategy:
|
|
10
|
+
{{- if .Values.strategy }}
|
|
11
|
+
{{- toYaml .Values.strategy | nindent 4 }}
|
|
12
|
+
{{- else }}
|
|
10
13
|
type: RollingUpdate
|
|
11
14
|
rollingUpdate:
|
|
12
15
|
maxSurge: 2
|
|
13
16
|
maxUnavailable: 50%
|
|
14
|
-
|
|
17
|
+
{{- end }}
|
|
18
|
+
replicas: {{ if hasKey .Values "replicas" }}{{ .Values.replicas }}{{ else if eq $.Values.envType "prod" }} 2 {{ else }} 1 {{ end }}
|
|
15
19
|
selector:
|
|
16
20
|
matchLabels:
|
|
17
21
|
app: {{ $.Values.app }}
|
|
@@ -20,41 +24,75 @@ spec:
|
|
|
20
24
|
labels:
|
|
21
25
|
app: {{ $.Values.app }}
|
|
22
26
|
spec:
|
|
27
|
+
{{- with .Values.podSecurityContext }}
|
|
28
|
+
securityContext:
|
|
29
|
+
{{- toYaml . | nindent 8 }}
|
|
30
|
+
{{- end }}
|
|
31
|
+
{{- with .Values.terminationGracePeriodSeconds }}
|
|
32
|
+
terminationGracePeriodSeconds: {{ . }}
|
|
33
|
+
{{- end }}
|
|
23
34
|
imagePullSecrets:
|
|
24
35
|
- name: {{ $.Values.imagePullSecret }}
|
|
25
36
|
containers:
|
|
26
37
|
- name: server
|
|
27
38
|
imagePullPolicy: Always
|
|
28
39
|
image: "{{ $.Values.image }}"
|
|
40
|
+
{{- with .Values.resources }}
|
|
29
41
|
resources:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
{{- toYaml . | nindent 12 }}
|
|
43
|
+
{{- end }}
|
|
44
|
+
{{- with .Values.containerSecurityContext }}
|
|
45
|
+
securityContext:
|
|
46
|
+
{{- toYaml . | nindent 12 }}
|
|
47
|
+
{{- end }}
|
|
34
48
|
env:
|
|
49
|
+
- name: HOST
|
|
50
|
+
value: "0.0.0.0"
|
|
51
|
+
- name: PORT
|
|
52
|
+
value: "80"
|
|
53
|
+
{{if $.Values.hostPrefix}}
|
|
35
54
|
- name: HOST_PREFIX
|
|
36
55
|
value: "{{ $.Values.hostPrefix }}"
|
|
37
56
|
{{end}}
|
|
38
|
-
{{-
|
|
57
|
+
{{- $hasAppUrl := false }}
|
|
58
|
+
{{- range .Values.env }}
|
|
59
|
+
{{- if eq .name "APP_URL" }}{{ $hasAppUrl = true }}{{- end }}
|
|
60
|
+
{{- end }}
|
|
61
|
+
{{- if and .Values.host (not $hasAppUrl) }}
|
|
62
|
+
- name: APP_URL
|
|
63
|
+
value: {{ printf "https://%s" .Values.host | quote }}
|
|
64
|
+
{{- end }}
|
|
65
|
+
{{- with .Values.env }}
|
|
66
|
+
{{- toYaml . | nindent 12 }}
|
|
67
|
+
{{- end }}
|
|
68
|
+
{{- if hasKey .Values "envFrom" }}
|
|
69
|
+
envFrom:
|
|
70
|
+
{{- toYaml .Values.envFrom | nindent 12 }}
|
|
71
|
+
{{- else if eq $.Values.targetK8s "saas" }}
|
|
39
72
|
envFrom:
|
|
40
73
|
- configMapRef:
|
|
41
74
|
name: "app-common-config"
|
|
42
75
|
{{- end }}
|
|
76
|
+
{{- with .Values.startupProbe }}
|
|
77
|
+
startupProbe:
|
|
78
|
+
{{- include "template.probe" (dict "probe" . "host" $.Values.host) | nindent 12 }}
|
|
79
|
+
{{- end }}
|
|
80
|
+
{{- with .Values.readinessProbe }}
|
|
81
|
+
readinessProbe:
|
|
82
|
+
{{- include "template.probe" (dict "probe" . "host" $.Values.host) | nindent 12 }}
|
|
83
|
+
{{- end }}
|
|
84
|
+
{{- with .Values.livenessProbe }}
|
|
85
|
+
livenessProbe:
|
|
86
|
+
{{- include "template.probe" (dict "probe" . "host" $.Values.host) | nindent 12 }}
|
|
87
|
+
{{- end }}
|
|
88
|
+
{{- if and .Values.persistence .Values.persistence.enabled }}
|
|
43
89
|
volumeMounts:
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- bash
|
|
49
|
-
- "-c"
|
|
50
|
-
- |
|
|
51
|
-
nginx
|
|
52
|
-
while :
|
|
53
|
-
do
|
|
54
|
-
sleep 10
|
|
55
|
-
done
|
|
90
|
+
- name: data
|
|
91
|
+
mountPath: {{ .Values.persistence.mountPath | quote }}
|
|
92
|
+
{{- end }}
|
|
93
|
+
{{- if and .Values.persistence .Values.persistence.enabled }}
|
|
56
94
|
volumes:
|
|
57
|
-
- name:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
- name: data
|
|
96
|
+
persistentVolumeClaim:
|
|
97
|
+
claimName: {{ default (printf "%s-data" .Values.app) .Values.persistence.existingClaim }}
|
|
98
|
+
{{- end }}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{- if and .Values.persistence .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: PersistentVolumeClaim
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ .Values.app }}-data
|
|
6
|
+
namespace: {{ include "template.namespace" . }}
|
|
7
|
+
annotations:
|
|
8
|
+
helm.sh/resource-policy: keep
|
|
9
|
+
spec:
|
|
10
|
+
accessModes: [ReadWriteOnce]
|
|
11
|
+
{{- with .Values.persistence.storageClass }}
|
|
12
|
+
storageClassName: {{ . | quote }}
|
|
13
|
+
{{- end }}
|
|
14
|
+
resources:
|
|
15
|
+
requests:
|
|
16
|
+
storage: {{ .Values.persistence.size }}
|
|
17
|
+
{{- end }}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
{{- define "template.namespace" -}}
|
|
2
2
|
{{ if not (empty .Values.namespace) }}{{ .Values.namespace }}{{ else }}deployment-{{ .Values.envType }}{{ end }}
|
|
3
3
|
{{- end -}}
|
|
4
|
+
|
|
5
|
+
{{/* HTTP 探针复用业务 host,并保留调用方显式设置的 Host 与其他请求头。 */}}
|
|
6
|
+
{{- define "template.probe" -}}
|
|
7
|
+
{{- $probe := deepCopy .probe -}}
|
|
8
|
+
{{- if and .host $probe.httpGet -}}
|
|
9
|
+
{{- $headers := $probe.httpGet.httpHeaders | default list -}}
|
|
10
|
+
{{- $hasHost := false -}}
|
|
11
|
+
{{- range $headers -}}
|
|
12
|
+
{{- if eq (lower .name) "host" -}}{{- $hasHost = true -}}{{- end -}}
|
|
13
|
+
{{- end -}}
|
|
14
|
+
{{- if not $hasHost -}}
|
|
15
|
+
{{- $_ := set $probe.httpGet "httpHeaders" (append $headers (dict "name" "Host" "value" .host)) -}}
|
|
16
|
+
{{- end -}}
|
|
17
|
+
{{- end -}}
|
|
18
|
+
{{- toYaml $probe -}}
|
|
19
|
+
{{- end -}}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
{{- if .Values.virtualService.enabled }}
|
|
1
|
+
{{- if and .Values.virtualService .Values.virtualService.enabled }}
|
|
2
|
+
{{- $hosts := get (.Values.virtualService.hosts | default dict) .Values.envType | default list }}
|
|
3
|
+
{{- if .Values.host }}{{ $hosts = prepend $hosts .Values.host | uniq }}{{- end }}
|
|
4
|
+
{{- if $hosts }}
|
|
2
5
|
apiVersion: networking.istio.io/v1alpha3
|
|
3
6
|
kind: VirtualService
|
|
4
7
|
metadata:
|
|
@@ -6,8 +9,7 @@ metadata:
|
|
|
6
9
|
namespace: {{ include "template.namespace" . }}
|
|
7
10
|
spec:
|
|
8
11
|
hosts:
|
|
9
|
-
|
|
10
|
-
{{- range $host }}
|
|
12
|
+
{{- range $hosts }}
|
|
11
13
|
- "{{ . }}"
|
|
12
14
|
{{- end }}
|
|
13
15
|
gateways:
|
|
@@ -19,14 +21,17 @@ spec:
|
|
|
19
21
|
- match:
|
|
20
22
|
- uri:
|
|
21
23
|
prefix: /
|
|
24
|
+
{{- with .Values.virtualService.timeout }}
|
|
25
|
+
timeout: {{ . }}
|
|
26
|
+
{{- end }}
|
|
22
27
|
route:
|
|
23
28
|
- destination:
|
|
24
29
|
host: {{ .Values.app }}
|
|
25
30
|
port:
|
|
26
31
|
number: 80
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
{{- with .Values.virtualService.corsPolicy }}
|
|
33
|
+
corsPolicy:
|
|
34
|
+
{{- toYaml . | nindent 8 }}
|
|
35
|
+
{{- end }}
|
|
36
|
+
{{- end }}
|
|
32
37
|
{{- end }}
|