docs(deploy): Complete full system deployment to Aliyun SAE
Summary: - Successfully deployed complete system to Aliyun SAE (2025-12-25) - All services running: Python microservice + Node.js backend + Frontend Nginx + CLB - Public access available at http://8.140.53.236/ Major Achievements: 1. Python microservice deployed (v1.0, internal IP: 172.17.173.66:8000) 2. Node.js backend deployed (v1.3, internal IP: 172.17.173.73:3001) - Fixed 4 critical issues: bash path, config directory, pino-pretty, ES Module 3. Frontend Nginx deployed (v1.0, internal IP: 172.17.173.72:80) 4. CLB load balancer configured (public IP: 8.140.53.236) New Documentation (9 docs): - 11-Node.js backend SAE deployment config checklist (21 env vars) - 12-Node.js backend SAE deployment operation manual - 13-Node.js backend image fix record (config directory) - 14-Node.js backend pino-pretty fix - 15-Node.js backend deployment success summary - 16-Frontend Nginx deployment success summary - 17-Complete deployment practical manual 2025 edition (1800 lines) - 18-Deployment documentation usage guide - 19-Daily update quick operation manual (670 lines) Key Fixes: - Environment variable name correction: EXTRACTION_SERVICE_URL (not PYTHON_SERVICE_URL) - Dockerfile fix: added COPY config ./config - Logger configuration: conditional pino-pretty for dev only - Health check fix: ES Module compatibility (require -> import) Updated Files: - System status document updated with full deployment info - Deployment progress overview updated with latest IPs - All 3 Docker services' Dockerfiles and configs refined Verification: - All health checks passed - Tool C 7 features working correctly - Literature screening module functional - Response time < 1 second BREAKING CHANGE: Node.js backend internal IP changed from 172.17.173.71 to 172.17.173.73 Closes #deployment-milestone
This commit is contained in:
@@ -28,6 +28,9 @@ RUN npx prisma generate
|
||||
# 5. 复制本地已编译好的 dist 文件夹(跳过TypeScript编译)
|
||||
COPY dist ./dist
|
||||
|
||||
# 6. 复制配置文件(agents.yaml等)
|
||||
COPY config ./config
|
||||
|
||||
# ==================== 阶段 2: 运行阶段 ====================
|
||||
FROM node:alpine
|
||||
|
||||
@@ -55,6 +58,7 @@ COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
|
||||
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
|
||||
COPY --from=builder --chown=nodejs:nodejs /app/package*.json ./
|
||||
COPY --from=builder --chown=nodejs:nodejs /app/prisma ./prisma
|
||||
COPY --from=builder --chown=nodejs:nodejs /app/config ./config
|
||||
|
||||
# 创建上传目录(用于临时文件)
|
||||
RUN mkdir -p /app/uploads && chown -R nodejs:nodejs /app/uploads
|
||||
|
||||
@@ -42,5 +42,6 @@ WHERE table_schema = 'dc_schema'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -82,3 +82,4 @@ ORDER BY ordinal_position;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -95,3 +95,4 @@ runMigration()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,5 +27,6 @@ COMMENT ON COLUMN "dc_schema"."dc_tool_c_sessions"."column_mapping" IS '列名
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -54,5 +54,6 @@ COMMENT ON COLUMN dc_schema.dc_tool_c_sessions.expires_at IS '过期时间(创
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
99
backend/rebuild-and-push.ps1
Normal file
99
backend/rebuild-and-push.ps1
Normal file
@@ -0,0 +1,99 @@
|
||||
# Node.js后端 - 重新构建并推送镜像到ACR
|
||||
# 创建时间: 2025-12-24
|
||||
# 原因: 修复缺少config目录的问题
|
||||
|
||||
Write-Host "============================================" -ForegroundColor Cyan
|
||||
Write-Host "🚀 Node.js后端 - 重新构建镜像" -ForegroundColor Cyan
|
||||
Write-Host "============================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# 1. 确认当前目录
|
||||
$currentDir = Get-Location
|
||||
Write-Host "📁 当前目录: $currentDir" -ForegroundColor Yellow
|
||||
if ($currentDir.Path -notlike "*\backend") {
|
||||
Write-Host "❌ 错误: 请在 backend 目录下运行此脚本!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 2. 检查必需文件
|
||||
Write-Host ""
|
||||
Write-Host "🔍 检查必需文件..." -ForegroundColor Yellow
|
||||
$requiredFiles = @("Dockerfile", "dist", "config", "package.json", "prisma")
|
||||
foreach ($file in $requiredFiles) {
|
||||
if (Test-Path $file) {
|
||||
Write-Host " ✅ $file" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " ❌ $file 不存在!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# 3. 登录ACR
|
||||
Write-Host ""
|
||||
Write-Host "🔐 登录阿里云容器镜像服务 (ACR)..." -ForegroundColor Yellow
|
||||
docker login `
|
||||
--username=gofeng117@163.com `
|
||||
--password=fengzhibo117 `
|
||||
crpi-cd5ij4pjt65mweeo.cn-beijing.personal.cr.aliyuncs.com
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ ACR登录失败!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✅ ACR登录成功" -ForegroundColor Green
|
||||
|
||||
# 4. 构建镜像
|
||||
Write-Host ""
|
||||
Write-Host "🏗️ 开始构建Docker镜像..." -ForegroundColor Yellow
|
||||
Write-Host " 镜像名称: backend-service:v1.1" -ForegroundColor Cyan
|
||||
Write-Host " 修复内容: 添加config目录(agents.yaml等配置文件)" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
$imageName = "crpi-cd5ij4pjt65mweeo.cn-beijing.personal.cr.aliyuncs.com/ai-clinical/backend-service"
|
||||
$imageTag = "v1.1"
|
||||
|
||||
docker build -t "${imageName}:${imageTag}" .
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ 镜像构建失败!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✅ 镜像构建成功: ${imageName}:${imageTag}" -ForegroundColor Green
|
||||
|
||||
# 5. 推送镜像到ACR
|
||||
Write-Host ""
|
||||
Write-Host "📤 推送镜像到ACR..." -ForegroundColor Yellow
|
||||
docker push "${imageName}:${imageTag}"
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ 镜像推送失败!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✅ 镜像推送成功" -ForegroundColor Green
|
||||
|
||||
# 6. 同时打上latest标签(可选)
|
||||
Write-Host ""
|
||||
Write-Host "🏷️ 打上latest标签..." -ForegroundColor Yellow
|
||||
docker tag "${imageName}:${imageTag}" "${imageName}:latest"
|
||||
docker push "${imageName}:latest"
|
||||
Write-Host "✅ latest标签已推送" -ForegroundColor Green
|
||||
|
||||
# 7. 完成
|
||||
Write-Host ""
|
||||
Write-Host "============================================" -ForegroundColor Cyan
|
||||
Write-Host "🎉 镜像构建和推送完成!" -ForegroundColor Green
|
||||
Write-Host "============================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "📋 镜像信息:" -ForegroundColor Yellow
|
||||
Write-Host " 公网地址: ${imageName}:${imageTag}" -ForegroundColor Cyan
|
||||
Write-Host " VPC地址: crpi-cd5ij4pjt65mweeo-vpc.cn-beijing.personal.cr.aliyuncs.com/ai-clinical/backend-service:${imageTag}" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "📝 下一步操作:" -ForegroundColor Yellow
|
||||
Write-Host " 1. 登录SAE控制台: https://sae.console.aliyun.com/" -ForegroundColor White
|
||||
Write-Host " 2. 找到应用: nodejs-backend-test" -ForegroundColor White
|
||||
Write-Host " 3. 配置管理 → 部署配置 → 镜像设置" -ForegroundColor White
|
||||
Write-Host " 4. 修改镜像版本为: v1.1" -ForegroundColor White
|
||||
Write-Host " 5. 保存并重新部署" -ForegroundColor White
|
||||
Write-Host ""
|
||||
|
||||
|
||||
@@ -204,5 +204,6 @@ function extractCodeBlocks(obj, blocks = []) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -223,5 +223,6 @@ checkDCTables();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -175,5 +175,6 @@ createAiHistoryTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -162,5 +162,6 @@ createToolCTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -159,5 +159,6 @@ createToolCTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'
|
||||
import { prisma, getDatabaseConnectionCount } from '../../config/database.js'
|
||||
import os from 'os'
|
||||
|
||||
/**
|
||||
* 健康检查响应
|
||||
@@ -201,7 +202,7 @@ export async function registerHealthRoutes(app: FastifyInstance): Promise<void>
|
||||
// ========== CPU信息 ==========
|
||||
checks.cpu = {
|
||||
usage: process.cpuUsage(),
|
||||
loadAverage: process.platform !== 'win32' ? require('os').loadavg() : 'N/A'
|
||||
loadAverage: process.platform !== 'win32' ? os.loadavg() : 'N/A'
|
||||
}
|
||||
|
||||
// ========== 返回响应 ==========
|
||||
|
||||
@@ -293,3 +293,4 @@ export function getBatchItems<T>(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,18 +26,25 @@ import { jobQueue } from './common/jobs/index.js';
|
||||
return Number(this);
|
||||
};
|
||||
|
||||
// 生产环境使用JSON格式日志(性能更好),开发环境使用pino-pretty(易读)
|
||||
const fastify = Fastify({
|
||||
logger: {
|
||||
level: config.logLevel,
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
translateTime: 'HH:MM:ss Z',
|
||||
ignore: 'pid,hostname',
|
||||
logger: config.nodeEnv === 'production'
|
||||
? {
|
||||
level: config.logLevel,
|
||||
// 生产环境:简单的JSON日志,适合日志收集系统
|
||||
}
|
||||
: {
|
||||
level: config.logLevel,
|
||||
// 开发环境:使用pino-pretty美化输出
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
translateTime: 'HH:MM:ss Z',
|
||||
ignore: 'pid,hostname',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// 注册CORS插件 - 完整配置
|
||||
|
||||
@@ -327,5 +327,6 @@ runTests().catch((error) => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -268,5 +268,6 @@ runTest()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -306,5 +306,6 @@ Content-Type: application/json
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -242,5 +242,6 @@ export const conflictDetectionService = new ConflictDetectionService();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -192,5 +192,6 @@ curl -X POST http://localhost:3000/api/v1/dc/tool-c/test/execute \
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -246,5 +246,6 @@ export const streamAIController = new StreamAIController();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -394,3 +394,4 @@ SET session_replication_role = 'origin';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -96,3 +96,4 @@ WHERE key = 'verify_test';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -239,3 +239,4 @@ verifyDatabase()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1
backend/src/types/global.d.ts
vendored
1
backend/src/types/global.d.ts
vendored
@@ -29,3 +29,4 @@ export {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,5 +50,6 @@ Write-Host "✅ 完成!" -ForegroundColor Green
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -337,5 +337,6 @@ runAdvancedTests().catch(error => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -403,5 +403,6 @@ runAllTests()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -361,5 +361,6 @@ runAllTests()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user