1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-02-03 02:23:38 +08:00
Files
408CSFamily/scripts/bundle
2024-10-16 16:06:14 +08:00

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 process from 'node:process'
import {
OPEN_SOURCE_ADDRESS,
buildImage,
getRecentGitCommit,
} 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 { hash: gitHash } = await getRecentGitCommit()
// 构建镜像
await buildImage({
imageName,
buildArgs: [
// 参数中是否包含 --proxy
['NEED_PROXY', process.argv.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', gitHash],
],
memory: 20000,
push: true,
delete: true,
logger: true,
})
}
catch (e) {
console.log('异常信息:', e)
}
})()