feat: 添加 Docker Hub 自动构建和改进部署体验

- 支持环境变量预设管理员账号密码
- 添加 docker-entrypoint.sh 自动初始化脚本
- 配置 GitHub Actions 自动构建多平台镜像(amd64, arm64)
- 添加版本标签管理和自动发布流程
- 集成 Trivy 安全漏洞扫描
- 更新文档说明 Docker Hub 使用方法
- 优化 Docker 部署用户体验

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
shaw
2025-07-19 00:49:04 +08:00
parent f5968e518e
commit 5c83cf1d53
12 changed files with 691 additions and 6 deletions

View File

@@ -42,9 +42,14 @@ async function setup() {
fs.writeFileSync(path.join(__dirname, '..', '.env'), envContent);
}
// 3. 生成随机管理员凭据
const adminUsername = `cr_admin_${crypto.randomBytes(4).toString('hex')}`;
const adminPassword = crypto.randomBytes(16).toString('base64').replace(/[^a-zA-Z0-9]/g, '').substring(0, 16);
// 3. 生成或使用环境变量中的管理员凭据
const adminUsername = process.env.ADMIN_USERNAME || `cr_admin_${crypto.randomBytes(4).toString('hex')}`;
const adminPassword = process.env.ADMIN_PASSWORD || crypto.randomBytes(16).toString('base64').replace(/[^a-zA-Z0-9]/g, '').substring(0, 16);
// 如果使用了环境变量,显示提示
if (process.env.ADMIN_USERNAME || process.env.ADMIN_PASSWORD) {
console.log(chalk.yellow('\n📌 使用环境变量中的管理员凭据'));
}
// 4. 创建初始化完成标记文件
const initData = {
@@ -65,7 +70,14 @@ async function setup() {
console.log(chalk.yellow('📋 重要信息:\n'));
console.log(` 管理员用户名: ${chalk.cyan(adminUsername)}`);
console.log(` 管理员密码: ${chalk.cyan(adminPassword)}`);
console.log(chalk.red('\n⚠ 请立即保存这些凭据!首次登录后建议修改密码。\n'));
// 如果是自动生成的凭据,强调需要保存
if (!process.env.ADMIN_USERNAME && !process.env.ADMIN_PASSWORD) {
console.log(chalk.red('\n⚠ 请立即保存这些凭据!首次登录后建议修改密码。'));
console.log(chalk.yellow('\n💡 提示: 也可以通过环境变量 ADMIN_USERNAME 和 ADMIN_PASSWORD 预设管理员凭据。\n'));
} else {
console.log(chalk.green('\n✅ 已使用预设的管理员凭据。\n'));
}
console.log(chalk.blue('🚀 启动服务:\n'));
console.log(' npm start - 启动生产服务');