1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-02-04 11:03:24 +08:00
Files
408CSFamily/scripts/core/build-image.ts

50 lines
1.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { OPEN_SOURCE_ADDRESS, OPEN_SOURCE_AUTHOR } from '@142vip/open-source'
import {
VipConsole,
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 shortGitHash = 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', shortGitHash],
],
memory: 20000,
push: true,
delete: true,
logger: true,
})
}
catch (e) {
VipConsole.trace('异常信息:', e)
}
}
void buildImageMain()