@winner-fed/winner-deploy 2.0.13 → 3.0.3
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/package.json +1 -1
- package/src/GeneratorSeePackage.js +17 -11
- package/src/genDockerPackage.js +88 -0
- package/src/genZipPackage.js +17 -34
- package/src/see.js +61 -1
- package/src/utils.js +33 -0
- package/src/winner-deploy.js +33 -5
- package/templates/see/1.x/deploy.xml +5 -5
- package/templates/see/2.x/deploy.xml +8 -8
- package/templates/see/docker/Dockerfile +8 -0
- package/templates/see/docker/deploy.xml +47 -0
- package/templates/see/docker/template/k8s-deploy-res.yaml +76 -0
package/package.json
CHANGED
|
@@ -13,8 +13,14 @@ const TypesSupported = ['input', 'select', 'switch', 'smallfile', 'table']
|
|
|
13
13
|
const tmp = 'tmp'
|
|
14
14
|
|
|
15
15
|
module.exports = class Generator {
|
|
16
|
-
constructor(packageInfo, sysconfig = './dist/config.local.js', variables = []) {
|
|
17
|
-
const {
|
|
16
|
+
constructor (packageInfo, sysconfig = './dist/config.local.js', variables = []) {
|
|
17
|
+
const {
|
|
18
|
+
system = 'winner-front',
|
|
19
|
+
type = 'app',
|
|
20
|
+
name = '',
|
|
21
|
+
version = '1.0.0',
|
|
22
|
+
configFileName = 'config.local'
|
|
23
|
+
} = packageInfo
|
|
18
24
|
|
|
19
25
|
this.packageInfo = {
|
|
20
26
|
system,
|
|
@@ -28,7 +34,7 @@ module.exports = class Generator {
|
|
|
28
34
|
this.templateVariables = variables
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
generate(handler, packageName) {
|
|
37
|
+
generate (handler, packageName) {
|
|
32
38
|
return new Promise((resolve, reject) => {
|
|
33
39
|
this.packageName = packageName || this.packageInfo.name + '-' + Date.now()
|
|
34
40
|
|
|
@@ -50,7 +56,7 @@ module.exports = class Generator {
|
|
|
50
56
|
})
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
genDeployXml() {
|
|
59
|
+
genDeployXml () {
|
|
54
60
|
fs.outputFileSync(
|
|
55
61
|
`./${tmp}/deploy.xml`,
|
|
56
62
|
tpl(fs.readFileSync(resolve('/deploy.xml')))({
|
|
@@ -62,7 +68,7 @@ module.exports = class Generator {
|
|
|
62
68
|
)
|
|
63
69
|
}
|
|
64
70
|
|
|
65
|
-
genXmlField(attr) {
|
|
71
|
+
genXmlField (attr) {
|
|
66
72
|
const genCommonField = (attr) => {
|
|
67
73
|
const { type } = attr
|
|
68
74
|
if (!TypesSupported.includes(type)) return ''
|
|
@@ -112,7 +118,7 @@ module.exports = class Generator {
|
|
|
112
118
|
return genCommonField(attr)
|
|
113
119
|
}
|
|
114
120
|
|
|
115
|
-
genScripts() {
|
|
121
|
+
genScripts () {
|
|
116
122
|
fs.ensureDirSync(`${tmp}/scripts`)
|
|
117
123
|
fs.outputFileSync(
|
|
118
124
|
`./${tmp}/scripts/${this.packageInfo.name}/install.sh`,
|
|
@@ -124,15 +130,15 @@ module.exports = class Generator {
|
|
|
124
130
|
)
|
|
125
131
|
}
|
|
126
132
|
|
|
127
|
-
genTemplate() {
|
|
133
|
+
genTemplate () {
|
|
128
134
|
const { templateFile, templateVariables } = this
|
|
129
135
|
let { code } = babel.transformFileSync(templateFile, {
|
|
130
136
|
babelrc: false,
|
|
131
137
|
plugins: [
|
|
132
|
-
function seeTemplatePlugin() {
|
|
138
|
+
function seeTemplatePlugin () {
|
|
133
139
|
return {
|
|
134
140
|
visitor: {
|
|
135
|
-
Literal(path) {
|
|
141
|
+
Literal (path) {
|
|
136
142
|
if (path.parentPath.isProperty()) {
|
|
137
143
|
const _match = templateVariables.find(
|
|
138
144
|
(variable) => path.parentPath.get('key').node.name === variable.name
|
|
@@ -149,7 +155,7 @@ module.exports = class Generator {
|
|
|
149
155
|
}
|
|
150
156
|
}
|
|
151
157
|
},
|
|
152
|
-
ArrayExpression(path) {
|
|
158
|
+
ArrayExpression (path) {
|
|
153
159
|
if (path.parentPath.isProperty()) {
|
|
154
160
|
const _match = templateVariables.find(
|
|
155
161
|
(variable) => path.parentPath.get('key').node.name === variable.name
|
|
@@ -191,7 +197,7 @@ module.exports = class Generator {
|
|
|
191
197
|
fs.outputFileSync(`./${tmp}/template/${this.packageInfo.name}/config.local.js`, code)
|
|
192
198
|
}
|
|
193
199
|
|
|
194
|
-
genPackage(cb) {
|
|
200
|
+
genPackage (cb) {
|
|
195
201
|
const output = fs.createWriteStream(`${this.packageName}.zip`)
|
|
196
202
|
|
|
197
203
|
output.on('close', function() {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs-extra')
|
|
3
|
+
const rm = require('rimraf')
|
|
4
|
+
|
|
5
|
+
const { isWinnerProject, isProProject, genZipPackage } = require('./utils')
|
|
6
|
+
const { genDockerDeployXml, genTemplate, genDockerfile, genK8sDeployRes } = require('./see')
|
|
7
|
+
|
|
8
|
+
const tmp = 'tmp'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 生成 docker 包
|
|
12
|
+
* 自动生成 SEE 平台的发布物和构建镜像所需的文本文件 Dockerfile
|
|
13
|
+
* @description 系统类型、应用类型和版本决定了发布物的唯一性
|
|
14
|
+
* @param seePackageName
|
|
15
|
+
* @param options
|
|
16
|
+
* @property {options.system} 系统类型, SEE 平台的分组是以系统类型字段纬度来的
|
|
17
|
+
* @property {options.type} 应用类型, 外框架 - bizframe | 子系统 - subsystem
|
|
18
|
+
* @property {options.name} 发布物名称
|
|
19
|
+
* @property {options.appType} 发布物类型
|
|
20
|
+
* @property {options.version} 发布包版本
|
|
21
|
+
* @property {options.configName} 配置文件名称 winner - config.local pro - sysconfig
|
|
22
|
+
* @param handler
|
|
23
|
+
*/
|
|
24
|
+
exports.genDockerPackage = function genDockerPackage (seePackageName, options, handler) {
|
|
25
|
+
let {
|
|
26
|
+
system,
|
|
27
|
+
type,
|
|
28
|
+
name,
|
|
29
|
+
appType,
|
|
30
|
+
version,
|
|
31
|
+
template,
|
|
32
|
+
variables,
|
|
33
|
+
configName: configFileName,
|
|
34
|
+
description
|
|
35
|
+
} = options
|
|
36
|
+
fs.ensureDirSync(tmp)
|
|
37
|
+
|
|
38
|
+
// 项目根目录下 Dockerfile 文件
|
|
39
|
+
fs.ensureDirSync('docker')
|
|
40
|
+
fs.outputFileSync(path.resolve(process.cwd(), `docker/Dockerfile`), genDockerfile({ name }));
|
|
41
|
+
|
|
42
|
+
// 缺少 scripts 目录会导致 SEE 平台上传发布物报错
|
|
43
|
+
fs.ensureDirSync(`${tmp}/scripts`);
|
|
44
|
+
|
|
45
|
+
// 缺少 template 目录会导致 SEE 平台上传发布物报错
|
|
46
|
+
fs.ensureDirSync(`${tmp}/template`)
|
|
47
|
+
|
|
48
|
+
if (isWinnerProject()) {
|
|
49
|
+
fs.outputFileSync(`./${tmp}/template/${name}/config.local.js`, template ? genTemplate(template, variables) : '')
|
|
50
|
+
} else if (isProProject() || isProProject(name)) { // 子包目录 dist/'name'/sysconfig.js
|
|
51
|
+
// 这里做了默认重写
|
|
52
|
+
// 兼容操作员中心产品
|
|
53
|
+
configFileName = 'sysconfig';
|
|
54
|
+
fs.outputFileSync(`./${tmp}/template/${name}/sysconfig.js`, template ? genTemplate(template, variables) : '')
|
|
55
|
+
} else {
|
|
56
|
+
// 自定义配置文件的名字
|
|
57
|
+
fs.outputFileSync(`./${tmp}/template/${name}/${configFileName}.js`, template ? genTemplate(template, variables) : '')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 生成 k8s-deploy-res.yaml
|
|
61
|
+
fs.outputFileSync(`./${tmp}/template/k8s-deploy-res.yaml`, genK8sDeployRes({ configFileName }))
|
|
62
|
+
|
|
63
|
+
fs.outputFileSync(`./${tmp}/deploy.xml`, genDockerDeployXml({
|
|
64
|
+
system,
|
|
65
|
+
type,
|
|
66
|
+
name,
|
|
67
|
+
appType,
|
|
68
|
+
version,
|
|
69
|
+
configFileName,
|
|
70
|
+
variables,
|
|
71
|
+
description,
|
|
72
|
+
web_app_web_service_name: `${name}-web`,
|
|
73
|
+
dockerImage: version.indexOf('-') > 0 ? `ws6.0-docker-dev-local/${name}` : `ws6.0-docker-release-local/${name}`
|
|
74
|
+
}))
|
|
75
|
+
|
|
76
|
+
if (handler) {
|
|
77
|
+
handler((cb) => {
|
|
78
|
+
genZipPackage(seePackageName, tmp, () => {
|
|
79
|
+
rm.sync(tmp)
|
|
80
|
+
typeof cb === 'function' && cb()
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
} else {
|
|
84
|
+
genZipPackage(seePackageName, tmp, () => {
|
|
85
|
+
rm.sync(tmp)
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/genZipPackage.js
CHANGED
|
@@ -2,40 +2,12 @@ const chalk = require('chalk')
|
|
|
2
2
|
const fs = require('fs-extra')
|
|
3
3
|
const rm = require('rimraf')
|
|
4
4
|
const GeneratorSeePackage = require('./GeneratorSeePackage')
|
|
5
|
-
const archiver = require('archiver')
|
|
6
5
|
|
|
7
|
-
const { getProjectConfig, spinner, isWinnerProject, isProProject } = require('./utils')
|
|
6
|
+
const { getProjectConfig, spinner, isWinnerProject, isProProject, genZipPackage } = require('./utils')
|
|
8
7
|
const { genDeployXml, genScripts, genTemplate } = require('./see')
|
|
9
8
|
|
|
10
9
|
const tmp = 'tmp'
|
|
11
10
|
|
|
12
|
-
/**
|
|
13
|
-
* 生成 zip
|
|
14
|
-
* @param zipPackageName
|
|
15
|
-
* @param cb
|
|
16
|
-
*/
|
|
17
|
-
function genZipPackage (zipPackageName, cb) {
|
|
18
|
-
const output = fs.createWriteStream(`${zipPackageName}.zip`)
|
|
19
|
-
|
|
20
|
-
output.on('close', function() {
|
|
21
|
-
setTimeout(function() {
|
|
22
|
-
cb && cb()
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const archive = archiver('zip', { zlib: { level: 9 } }) // Sets the compression level.
|
|
27
|
-
|
|
28
|
-
archive.on('error', function(error) {
|
|
29
|
-
console.error()
|
|
30
|
-
console.error(error.stack || error)
|
|
31
|
-
error.details && console.error(error.details)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
archive.pipe(output)
|
|
35
|
-
archive.directory(tmp, false)
|
|
36
|
-
archive.finalize()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
11
|
/**
|
|
40
12
|
* @description 系统类型、应用类型和版本决定了发布物的唯一性
|
|
41
13
|
* @param seePackageName
|
|
@@ -49,7 +21,17 @@ function genZipPackage (zipPackageName, cb) {
|
|
|
49
21
|
* @param handler
|
|
50
22
|
*/
|
|
51
23
|
exports.genSeePackage = function genSeePackage (seePackageName, options, handler) {
|
|
52
|
-
let {
|
|
24
|
+
let {
|
|
25
|
+
system,
|
|
26
|
+
type,
|
|
27
|
+
name,
|
|
28
|
+
appType,
|
|
29
|
+
version,
|
|
30
|
+
template,
|
|
31
|
+
variables,
|
|
32
|
+
configName: configFileName,
|
|
33
|
+
description
|
|
34
|
+
} = options
|
|
53
35
|
fs.ensureDirSync(tmp)
|
|
54
36
|
fs.ensureDirSync(`${tmp}/scripts`)
|
|
55
37
|
fs.outputFileSync(`./${tmp}/scripts/${name}/utils.py`, genScripts('utils'))
|
|
@@ -86,13 +68,14 @@ exports.genSeePackage = function genSeePackage (seePackageName, options, handler
|
|
|
86
68
|
}))
|
|
87
69
|
|
|
88
70
|
if (handler) {
|
|
89
|
-
handler(() => {
|
|
90
|
-
genZipPackage(seePackageName, () => {
|
|
71
|
+
handler((cb) => {
|
|
72
|
+
genZipPackage(seePackageName, tmp, () => {
|
|
91
73
|
rm.sync(tmp)
|
|
74
|
+
typeof cb === 'function' && cb()
|
|
92
75
|
})
|
|
93
76
|
})
|
|
94
77
|
} else {
|
|
95
|
-
genZipPackage(seePackageName, () => {
|
|
78
|
+
genZipPackage(seePackageName, tmp, () => {
|
|
96
79
|
rm.sync(tmp)
|
|
97
80
|
})
|
|
98
81
|
}
|
|
@@ -107,7 +90,7 @@ exports.genSeePackage2 = function genSeePackage2 (cb) {
|
|
|
107
90
|
const { see, type, name, version, configFileName } = getProjectConfig()
|
|
108
91
|
|
|
109
92
|
new GeneratorSeePackage(
|
|
110
|
-
{ system: see.systemType, type: see.appType || type, name, version, configFileName},
|
|
93
|
+
{ system: see.systemType, type: see.appType || type, name, version, configFileName },
|
|
111
94
|
'./dist/config.local.js',
|
|
112
95
|
see.variables
|
|
113
96
|
)
|
package/src/see.js
CHANGED
|
@@ -5,7 +5,16 @@ const xml = require('xml')
|
|
|
5
5
|
const babel = require('@babel/core')
|
|
6
6
|
const { unEscapeForXML } = require('./utils')
|
|
7
7
|
|
|
8
|
-
exports.genDeployXml = function genDeployXml ({
|
|
8
|
+
exports.genDeployXml = function genDeployXml ({
|
|
9
|
+
system,
|
|
10
|
+
type,
|
|
11
|
+
name,
|
|
12
|
+
appType,
|
|
13
|
+
version,
|
|
14
|
+
configFileName = 'config.local',
|
|
15
|
+
variables = [],
|
|
16
|
+
description
|
|
17
|
+
}) {
|
|
9
18
|
const template = fs.readFileSync(path.resolve(__dirname, `../templates/see/1.x/deploy.xml`))
|
|
10
19
|
|
|
11
20
|
return tpl(template)({
|
|
@@ -95,3 +104,54 @@ exports.genTemplate = function genTemplate (file, variables = []) {
|
|
|
95
104
|
return code.replace(/"\[NO_QUOTATION_MARKS](.*)\[NO_QUOTATION_MARKS]"/g, '$1')
|
|
96
105
|
}
|
|
97
106
|
|
|
107
|
+
// ---------------------------------------------------docker
|
|
108
|
+
exports.genDockerDeployXml = function genDockerDeployXml ({
|
|
109
|
+
system,
|
|
110
|
+
type,
|
|
111
|
+
name,
|
|
112
|
+
appType,
|
|
113
|
+
version,
|
|
114
|
+
configFileName = 'config.local',
|
|
115
|
+
variables = [],
|
|
116
|
+
description,
|
|
117
|
+
web_app_web_service_name,
|
|
118
|
+
dockerImage
|
|
119
|
+
}) {
|
|
120
|
+
const template = fs.readFileSync(path.resolve(__dirname, `../templates/see/docker/deploy.xml`))
|
|
121
|
+
|
|
122
|
+
return tpl(template)({
|
|
123
|
+
system,
|
|
124
|
+
type,
|
|
125
|
+
name,
|
|
126
|
+
appType,
|
|
127
|
+
version,
|
|
128
|
+
configFileName,
|
|
129
|
+
variables: (() => {
|
|
130
|
+
return variables
|
|
131
|
+
.map((attr) => {
|
|
132
|
+
const defaultValue = attr.default
|
|
133
|
+
delete attr.default
|
|
134
|
+
const xmlVariable = xml({ field: [{ _attr: attr }, defaultValue] })
|
|
135
|
+
return unEscapeForXML(`${xmlVariable}`)
|
|
136
|
+
})
|
|
137
|
+
.join('\n ')
|
|
138
|
+
})(),
|
|
139
|
+
description,
|
|
140
|
+
web_app_web_service_name,
|
|
141
|
+
dockerImage
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
exports.genK8sDeployRes = function genK8sDeployResYaml (options) {
|
|
146
|
+
const template = fs.readFileSync(path.resolve(__dirname, `../templates/see/docker/template/k8s-deploy-res.yaml`));
|
|
147
|
+
|
|
148
|
+
return tpl(template, {
|
|
149
|
+
interpolate: /{{([\s\S]+?)}}/g
|
|
150
|
+
})(options)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
exports.genDockerfile = function genDockerfile (options) {
|
|
154
|
+
const template = fs.readFileSync(path.resolve(__dirname, `../templates/see/docker/Dockerfile`))
|
|
155
|
+
|
|
156
|
+
return tpl(template)(options)
|
|
157
|
+
}
|
package/src/utils.js
CHANGED
|
@@ -2,6 +2,7 @@ const path = require('path')
|
|
|
2
2
|
const chalk = require('chalk')
|
|
3
3
|
const ora = require('ora')
|
|
4
4
|
const fs = require('fs-extra')
|
|
5
|
+
const archiver = require('archiver')
|
|
5
6
|
|
|
6
7
|
const context = process.cwd()
|
|
7
8
|
|
|
@@ -47,3 +48,35 @@ exports.isWinnerProject = function isWinnerProject () {
|
|
|
47
48
|
const configLocalJS = path.resolve(context, 'dist', 'config.local.js')
|
|
48
49
|
return fs.pathExistsSync(configLocalJS)
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 生成 zip
|
|
54
|
+
* @param zipPackageName
|
|
55
|
+
* @param tmp
|
|
56
|
+
* @param cb
|
|
57
|
+
*/
|
|
58
|
+
exports.genZipPackage = function genZipPackage (zipPackageName, tmp, cb) {
|
|
59
|
+
// 包存放路径
|
|
60
|
+
const packagePath = 'package'
|
|
61
|
+
fs.ensureDirSync(packagePath)
|
|
62
|
+
|
|
63
|
+
const output = fs.createWriteStream(`${packagePath}/${zipPackageName}.zip`)
|
|
64
|
+
|
|
65
|
+
output.on('close', function() {
|
|
66
|
+
setTimeout(function() {
|
|
67
|
+
cb && cb()
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const archive = archiver('zip', { zlib: { level: 9 } }) // Sets the compression level.
|
|
72
|
+
|
|
73
|
+
archive.on('error', function(error) {
|
|
74
|
+
console.error()
|
|
75
|
+
console.error(error.stack || error)
|
|
76
|
+
error.details && console.error(error.details)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
archive.pipe(output)
|
|
80
|
+
archive.directory(tmp, false)
|
|
81
|
+
archive.finalize()
|
|
82
|
+
}
|
package/src/winner-deploy.js
CHANGED
|
@@ -6,6 +6,7 @@ const fs = require('fs-extra')
|
|
|
6
6
|
const context = process.cwd()
|
|
7
7
|
|
|
8
8
|
const { genSeePackage } = require('./genZipPackage')
|
|
9
|
+
const { genDockerPackage } = require('./genDockerPackage')
|
|
9
10
|
|
|
10
11
|
function genManifest (type, name) {
|
|
11
12
|
let manifest = ''
|
|
@@ -67,6 +68,7 @@ function genManifest (type, name) {
|
|
|
67
68
|
* @param description {string} 发布包说明
|
|
68
69
|
* @param seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`
|
|
69
70
|
* @param cb {function} 回调函数,用于处理在组装 see 包后,压缩成 zip 包前可以自定义执行的动作
|
|
71
|
+
* @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
|
|
70
72
|
*/
|
|
71
73
|
exports.generateSeePackageZip = function generateSeePackageZip ({
|
|
72
74
|
system,
|
|
@@ -79,7 +81,8 @@ exports.generateSeePackageZip = function generateSeePackageZip ({
|
|
|
79
81
|
variablesFunc,
|
|
80
82
|
copyFiles,
|
|
81
83
|
description,
|
|
82
|
-
seePackageName
|
|
84
|
+
seePackageName,
|
|
85
|
+
seePackageType = 'web'
|
|
83
86
|
}, cb) {
|
|
84
87
|
if (!name || !version) {
|
|
85
88
|
throw new Error('应用名称和应用版本不能缺失~')
|
|
@@ -111,6 +114,33 @@ exports.generateSeePackageZip = function generateSeePackageZip ({
|
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
|
|
117
|
+
if (seePackageType === 'docker') {
|
|
118
|
+
genDockerPackage(
|
|
119
|
+
seePackageName || `${system}-${name}-${version}`,
|
|
120
|
+
{
|
|
121
|
+
system,
|
|
122
|
+
type,
|
|
123
|
+
name,
|
|
124
|
+
appType,
|
|
125
|
+
version,
|
|
126
|
+
configName,
|
|
127
|
+
template: (templateFunc)(),
|
|
128
|
+
variables: (variablesFunc)(),
|
|
129
|
+
description
|
|
130
|
+
},
|
|
131
|
+
done => {
|
|
132
|
+
|
|
133
|
+
console.log()
|
|
134
|
+
ora(
|
|
135
|
+
`docker 容器化部署的 SEE 发布物制作完成,您可以在 SEE 平台上传并部署应用。`
|
|
136
|
+
).succeed()
|
|
137
|
+
|
|
138
|
+
done(cb)
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
114
144
|
genSeePackage(
|
|
115
145
|
seePackageName || `${system}-${name}-${version}`,
|
|
116
146
|
{
|
|
@@ -151,16 +181,14 @@ exports.generateSeePackageZip = function generateSeePackageZip ({
|
|
|
151
181
|
});
|
|
152
182
|
}
|
|
153
183
|
|
|
154
|
-
// 自定义执行的操作
|
|
155
|
-
typeof cb === 'function' && cb()
|
|
156
|
-
|
|
157
|
-
done()
|
|
158
184
|
console.log()
|
|
159
185
|
ora(
|
|
160
186
|
`发布物制作完成,您可以在 SEE 平台上传并部署应用。注意:${chalk.yellow(
|
|
161
187
|
'子系统发布物的安装目录需要指定到具体的应用目录'
|
|
162
188
|
)}。比如/home/hsiar/hsiar-green/html/。\n`
|
|
163
189
|
).succeed()
|
|
190
|
+
|
|
191
|
+
done(cb)
|
|
164
192
|
}
|
|
165
193
|
)
|
|
166
194
|
}
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
<appType describe="发布物类型">${ appType }</appType>
|
|
8
8
|
<appDescribe describe="发布包说明">${ description }</appDescribe>
|
|
9
9
|
<version describe="发布包版本">${ version }</version>
|
|
10
|
-
<group
|
|
11
|
-
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)"
|
|
10
|
+
<group>bizframe</group>
|
|
11
|
+
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)"/>
|
|
12
12
|
</basic>
|
|
13
|
-
<globalConfig describe="系统全局配置"
|
|
13
|
+
<globalConfig describe="系统全局配置"/>
|
|
14
14
|
<subSystems describe="子系统集合">
|
|
15
15
|
<system id="${ name }" type="${ type }" name="${ name }" mode="cluster" front="">
|
|
16
|
-
<scale describe="集群规模"
|
|
16
|
+
<scale describe="集群规模"/>
|
|
17
17
|
<scripts describe="集群脚本集">
|
|
18
18
|
<script name="beforeInstall" path="" describe="安装前处理"/>
|
|
19
19
|
<script name="install" path="./scripts/${ name }/install.py" describe="部署"/>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<config path="./scripts/${ name }/install.py" encoding="UTF-8"/>
|
|
36
36
|
<config path="./scripts/${ name }/afterInstall.py" encoding="UTF-8"/>
|
|
37
37
|
<config path="./scripts/${ name }/uninstall.py" encoding="UTF-8"/>
|
|
38
|
-
<node describe="节点私有配置信息"
|
|
38
|
+
<node describe="节点私有配置信息"/>
|
|
39
39
|
</system>
|
|
40
40
|
</subSystems>
|
|
41
41
|
</deploy>
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
<basic describe="基本信息">
|
|
4
4
|
<packType describe="包类型" options="pack:全量包;patch:补丁包">pack</packType>
|
|
5
5
|
<systemType describe="系统类型">${ system }</systemType>
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
<appDescribe describe="
|
|
9
|
-
<version describe="
|
|
6
|
+
<appName describe="发布物名称">${ name }</appName>
|
|
7
|
+
<appType describe="发布物类型">${ type }</appType>
|
|
8
|
+
<appDescribe describe="发布包说明">${ description }</appDescribe>
|
|
9
|
+
<version describe="发布包版本">${ version }</version>
|
|
10
10
|
<group>bizframe</group>
|
|
11
|
-
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)"
|
|
11
|
+
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)" />
|
|
12
12
|
</basic>
|
|
13
|
-
<globalConfig describe="系统全局配置"
|
|
13
|
+
<globalConfig describe="系统全局配置" />
|
|
14
14
|
<subSystems describe="子系统集合">
|
|
15
15
|
<system id="${ name }" type="" name="${ name }" mode="cluster" front="">
|
|
16
|
-
<scale describe="集群规模"
|
|
16
|
+
<scale describe="集群规模" />
|
|
17
17
|
<scripts describe="集群脚本集">
|
|
18
18
|
<script name="beforeInstall" path="" describe="安装前处理"/>
|
|
19
19
|
<script name="install" path="./scripts/${ name }/install.sh" describe="部署"/>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<config path="./scripts/${ name }/install.sh" encoding="UTF-8"/>
|
|
36
36
|
<config path="./scripts/${ name }/afterInstall.sh" encoding="UTF-8"/>
|
|
37
37
|
<config path="./scripts/${ name }/uninstall.sh" encoding="UTF-8"/>
|
|
38
|
-
<node describe="节点私有配置信息"
|
|
38
|
+
<node describe="节点私有配置信息"/>
|
|
39
39
|
</system>
|
|
40
40
|
</subSystems>
|
|
41
41
|
</deploy>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<deploy name="" type="docker" arch="k8s">
|
|
3
|
+
<basic describe="基本信息">
|
|
4
|
+
<packType describe="包类型" options="pack:全量包;patch:补丁包">pack</packType>
|
|
5
|
+
<systemType describe="系统类型">${ system }</systemType>
|
|
6
|
+
<appType describe="应用类型">${ type }</appType>
|
|
7
|
+
<appName describe="应用名称">${ name }</appName>
|
|
8
|
+
<appDescribe describe="应用说明">${ description }</appDescribe>
|
|
9
|
+
<version describe="应用版本">${ version }</version>
|
|
10
|
+
<group>bizframe</group>
|
|
11
|
+
<packInEffect describe="影响的主包(只有补丁需要配置,填写主包的版本号)" />
|
|
12
|
+
</basic>
|
|
13
|
+
<globalConfig describe="系统全局配置" />
|
|
14
|
+
<subSystems describe="子系统集合">
|
|
15
|
+
<system id="${ name }" type="" name="${ name }" mode="cluster" front="">
|
|
16
|
+
<variables describe="集群基本参数">
|
|
17
|
+
<field name="user" label="安装用户" type="input">root</field>
|
|
18
|
+
<field name="workspace" label="前端安装目录" type="hidden">/html</field>
|
|
19
|
+
|
|
20
|
+
<!-- K8S部署配置 -->
|
|
21
|
+
<field name="division_k8s" label="K8S部署配置" type="division" fold="false">
|
|
22
|
+
<field name="web_app_web_service_name" label="Web服务名" type="input" required="false" tooltip="用于service的域名配置,需与HSIAR的路由对应,默认为${web_app_web_service_name}">${web_app_web_service_name}</field>
|
|
23
|
+
<field name="registry_url" label="镜像中心" type="input" required="false">package.hundsun.com</field>
|
|
24
|
+
<field name="image" label="镜像" type="input" required="true">${dockerImage}</field>
|
|
25
|
+
<field name="image_pull_policy" label="镜像拉取策略" visible="true" type="select" options="Always:Always;IfNotPresent:IfNotPresent;Never:Never">IfNotPresent</field>
|
|
26
|
+
<field name="image_pull_secrets_enable" label="镜像拉取凭证开启" type="switchForm" options="true:ON;false:OFF" default="true">
|
|
27
|
+
<field name="image_pull_secrets" label="镜像拉取凭证" type="input" required="true" visible="true">global</field>
|
|
28
|
+
</field>
|
|
29
|
+
<field name="restart_policy" label="调度重启策略" visible="true" type="select" options="Always:Always;Never:Never">Always</field>
|
|
30
|
+
<field name="replicas" label="集群副本数" type="input" validate="Integer" required="true">1</field>
|
|
31
|
+
<field name="resources_enable" label="资源配额开启" type="switchForm" options="true:ON;false:OFF" default="false">
|
|
32
|
+
<field name="cpu_req" label="CPU申请配额值" type="input" required="true" visible="true" tooltip="1000m为1核">100m</field>
|
|
33
|
+
<field name="cpu_limit" label="CPU最大限制值" type="input" required="true" visible="true" tooltip="1000m为1核">500m</field>
|
|
34
|
+
<field name="memory_req" label="内存申请配额值" type="input" required="true" visible="true" tooltip="可选单位大小(G | M)">200M</field>
|
|
35
|
+
<field name="memory_limit" label="内存最大限制值" type="input" required="true" visible="true" tooltip="可选单位大小(G | M)">500M</field>
|
|
36
|
+
</field>
|
|
37
|
+
<field name="liveness_probe_enable" label="存活检查探针开启" type="switch" options="true:ON;false:OFF">false</field>
|
|
38
|
+
</field>
|
|
39
|
+
|
|
40
|
+
${ variables }
|
|
41
|
+
</variables>
|
|
42
|
+
<config path="./${ name }/${ configFileName }.js" encoding="UTF-8"/>
|
|
43
|
+
<config reference="" encoding="utf-8" path="./k8s-deploy-res.yaml" />
|
|
44
|
+
<node describe="节点私有配置信息" />
|
|
45
|
+
</system>
|
|
46
|
+
</subSystems>
|
|
47
|
+
</deploy>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: Service
|
|
4
|
+
metadata:
|
|
5
|
+
name: ${web_app_web_service_name}
|
|
6
|
+
labels:
|
|
7
|
+
name: ${svc_id}-service
|
|
8
|
+
spec:
|
|
9
|
+
ports:
|
|
10
|
+
- name: "http"
|
|
11
|
+
port: 80
|
|
12
|
+
targetPort: 80
|
|
13
|
+
selector:
|
|
14
|
+
name: ${svc_id}
|
|
15
|
+
---
|
|
16
|
+
apiVersion: apps/v1
|
|
17
|
+
kind: Deployment
|
|
18
|
+
metadata:
|
|
19
|
+
name: ${svc_id}
|
|
20
|
+
spec:
|
|
21
|
+
replicas: ${replicas}
|
|
22
|
+
revisionHistoryLimit: 2
|
|
23
|
+
selector:
|
|
24
|
+
matchLabels:
|
|
25
|
+
name: ${svc_id}
|
|
26
|
+
template:
|
|
27
|
+
metadata:
|
|
28
|
+
labels:
|
|
29
|
+
name: ${svc_id}
|
|
30
|
+
spec:
|
|
31
|
+
imagePullPolicy: ${image_pull_policy}
|
|
32
|
+
#if(${image_pull_secrets_enable} == "true")
|
|
33
|
+
imagePullSecrets:
|
|
34
|
+
- name: ${image_pull_secrets}
|
|
35
|
+
#end
|
|
36
|
+
restartPolicy: ${restart_policy}
|
|
37
|
+
hostname: ${web_app_web_service_name}
|
|
38
|
+
containers:
|
|
39
|
+
- name: ${web_app_web_service_name}
|
|
40
|
+
image: ${registry_url}/${image}:${version}
|
|
41
|
+
env:
|
|
42
|
+
- name: TZ
|
|
43
|
+
value: Asia/Shanghai
|
|
44
|
+
ports:
|
|
45
|
+
- containerPort: 80
|
|
46
|
+
#if(${resources_enable} == "true")
|
|
47
|
+
resources:
|
|
48
|
+
requests:
|
|
49
|
+
cpu: ${cpu_req}
|
|
50
|
+
memory: ${memory_req}
|
|
51
|
+
limits:
|
|
52
|
+
cpu: ${cpu_limit}
|
|
53
|
+
memory: ${memory_limit}
|
|
54
|
+
#end
|
|
55
|
+
#if(${liveness_probe_enable} == "true")
|
|
56
|
+
livenessProbe:
|
|
57
|
+
httpGet:
|
|
58
|
+
scheme: HTTP
|
|
59
|
+
port: 80
|
|
60
|
+
path: /sysconfig.js
|
|
61
|
+
initialDelaySeconds: 5
|
|
62
|
+
periodSeconds: 3
|
|
63
|
+
timeoutSeconds: 3
|
|
64
|
+
successThreshold: 2
|
|
65
|
+
failureThreshold: 2
|
|
66
|
+
readinessProbe:
|
|
67
|
+
httpGet:
|
|
68
|
+
scheme: HTTP
|
|
69
|
+
port: 80
|
|
70
|
+
path: /sysconfig.js
|
|
71
|
+
initialDelaySeconds: 5
|
|
72
|
+
periodSeconds: 3
|
|
73
|
+
timeoutSeconds: 3
|
|
74
|
+
successThreshold: 2
|
|
75
|
+
failureThreshold: 2
|
|
76
|
+
#end
|