1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-02-04 02:53:21 +08:00
Files
408CSFamily/scripts/bundle

53 lines
1.2 KiB
JavaScript
Executable File
Raw 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.
#!/usr/bin/env node
/**
* 功能构建Docker镜像
* 使用:
* - ./scripts/bundle
* - ./scripts/bundle --proxy
*/
import { createRequire } from 'node:module'
import {
OPEN_SOURCE_ADDRESS,
VipDocker,
VipGit,
VipNodeJS,
} from '@142vip/utils'
(async () => {
try {
// 获取package.json文件
const pkg = createRequire(import.meta.url)('../package.json')
// 镜像地址
const imageName = `${OPEN_SOURCE_ADDRESS.DOCKER_ALIYUNCS_VIP}/docs:${pkg.name}-${pkg.version}`
// 最近一次提交信息
const shortGitHash = VipGit.getRecentCommitShortHash()
// 构建镜像
await VipDocker.buildImage({
imageName,
buildArgs: [
// 参数中是否包含 --proxy
['NEED_PROXY', VipNodeJS.getProcessArgv().includes('--proxy')],
['APP_NAME', pkg.name],
['APP_VERSION', pkg.version],
['APP_DESCRIPTION', pkg.description],
['AUTHOR', pkg.authorInfo.name],
['EMAIL', pkg.authorInfo.email],
['HOME_PAGE', pkg.authorInfo.homePage],
['GIT_HASH', shortGitHash],
],
memory: 20000,
push: true,
delete: true,
logger: true,
})
}
catch (e) {
console.log('异常信息:', e)
}
})()