-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-image.ts
More file actions
executable file
·41 lines (37 loc) · 1.18 KB
/
build-image.ts
File metadata and controls
executable file
·41 lines (37 loc) · 1.18 KB
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
import { OPEN_SOURCE_ADDRESS, OPEN_SOURCE_AUTHOR, VipDocker, VipGit, VipNodeJS, VipPackageJSON } from '@142vip/utils'
/**
* 功能:构建Docker镜像
*/
async function buildImageMain(): Promise<void> {
try {
// 获取package.json文件
const { name, version, description } = VipPackageJSON.getPackageJSON<{ description: string }>()
// 镜像地址
const imageName = `${OPEN_SOURCE_ADDRESS.DOCKER_ALIYUNCS_VIP}/docs:${name}-${version}`
// 最近一次提交信息
const gitShortHash = VipGit.getRecentCommitShortHash()
// 构建镜像
await VipDocker.buildImage({
imageName,
buildArgs: [
// 参数中是否包含 --proxy
['NEED_PROXY', VipNodeJS.getProcessArgv().includes('--proxy')],
['APP_NAME', name],
['APP_VERSION', version],
['APP_DESCRIPTION', description],
['AUTHOR', OPEN_SOURCE_AUTHOR.name],
['EMAIL', OPEN_SOURCE_AUTHOR.email],
['HOME_PAGE', OPEN_SOURCE_AUTHOR.homePage],
['GIT_HASH', gitShortHash],
],
memory: 20000,
push: true,
delete: true,
logger: true,
})
}
catch (e) {
console.log('异常信息:', e)
}
}
void buildImageMain()