# 13. Deployment Architecture 基于平台选择定义部署策略: ## 13.1 部署策略 **前端部署:** - **平台:** 多八多云端容器环境(8080端口) - **构建命令:** `npm run build` - **输出目录:** `dist/` - **CDN/边缘:** 容器内Nginx反向代理 **后端部署:** - **平台:** 多八多云端容器环境(8080端口) - **构建命令:** `npm run build` - **部署方式:** Node.js进程管理(PM2) ## 13.2 CI/CD流水线 ```yaml # .github/workflows/ci.yaml name: CI Pipeline on: push: branches: [main, develop] pull_request: branches: [main] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci - name: Run type check run: npm run type-check - name: Run linting run: npm run lint - name: Run tests run: npm run test build: runs-on: ubuntu-latest needs: test steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci - name: Build applications run: npm run build - name: Upload artifacts uses: actions/upload-artifact@v3 with: name: build-artifacts path: | apps/admin/dist apps/api/dist ``` ## 13.3 环境配置 | 环境 | 前端URL | 后端URL | 用途 | |------|---------|---------|------| | 开发 | http://localhost:3000 | http://localhost:8080 | 本地开发 | | 测试 | http://test.example.com | http://api.test.example.com | 预生产测试 | | 生产 | http://app.example.com | http://api.example.com | 生产环境 |