部署 (Deployment)¶
架构¶
应用程序部署为 Azure Static Web App (Azure 静态 Web 应用),它同时托管:
- React 前端(静态文件)
- Azure Functions API(无服务器后端)
GitHub Actions CI/CD¶
部署过程已通过 GitHub Actions 实现自动化。每当有代码推送到 main 分支时:
- GitHub Actions 工作流触发
- 构建前端 (在
/frontend目录下运行npm run build) - 构建 API (在
/api目录下运行npm run build) - 部署至 Azure Static Web Apps
工作流配置文件位于 .github/workflows/azure-static-web-apps-*.yml。
环境配置¶
Azure Static Web App 设置¶
请在 Azure 门户 -> 静态 Web 应用 -> 配置中进行以下配置:
| 设置项 | 描述 |
|---|---|
DATABASE_HOST |
Azure SQL 服务器主机名 |
DATABASE_NAME |
数据库名称 |
DATABASE_USER |
SQL 身份验证用户名 |
DATABASE_PASSWORD |
SQL 身份验证密码 |
数据库¶
- Azure SQL Database (标准层级)
- 使用
mssqlnpm 包进行连接,并支持连接池 - 每晚通过 Apache Airflow 从 Cin7 同步数据
手动部署¶
如果需要,可以使用 Azure SWA CLI 进行手动部署:
# 安装 SWA CLI
npm install -g @azure/static-web-apps-cli
# 构建两个项目
cd frontend && npm run build && cd ..
cd api && npm run build && cd ..
# 部署
swa deploy --app-location frontend/dist --api-location api
文档部署¶
文档网站独立部署至 Cloudflare Pages:
./cloudflare-pages-docs.sh
此脚本会将文档构建到 site 目录,然后发布到关联的 Cloudflare Pages 域名。