Files
ocdp-go/backend/scripts/quick-start-production.sh
Ivan087 7f238a3168 refactor: full-stack restructure with multi-tenancy, workspace management, and K8s diagnostics
- Add Workspace domain (entity, repository, service, handler, DTO)
- Add multi-tenant K8s client with tenant binding and quota management
- Add K8s diagnostics client (instance diagnostics)
- Add authorization middleware (authz package)
- Restructure frontend to feature-based architecture (features/)
- Add User Management page in configuration
- Add AccessDenied page and route guards
- Refactor shared components (form inputs, layout, UI)
- Update Tailwind config for new design system
- Add comprehensive documentation (docs/, tasks/, plans)
- Improve cluster service with better kubeconfig handling
- Add tests for crypto, config, helm client, tenant binding
2026-05-12 16:15:14 +08:00

85 lines
2.0 KiB
Bash
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.

#!/bin/bash
# OCDP Backend - Production 模式快速启动脚本
set -e
echo "🚀 OCDP Backend - Production 模式快速启动"
echo "========================================="
echo ""
# 检查 Docker
if ! command -v docker &> /dev/null; then
echo "❌ Docker 未安装,请先安装 Docker"
exit 1
fi
# 检查 docker compose
if ! docker compose version &> /dev/null; then
echo "❌ docker compose 未安装,请先安装 Docker Compose V2"
exit 1
fi
echo "✅ Docker 环境检查通过"
echo ""
# 获取项目根目录
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$( cd "$SCRIPT_DIR/../.." && pwd )"
# 启动 PostgreSQL从根目录
echo "📦 启动 PostgreSQL..."
cd "$PROJECT_ROOT"
docker compose up -d postgres
echo "⏳ 等待 PostgreSQL 就绪..."
sleep 5
# 检查 PostgreSQL 是否就绪
docker compose exec -T postgres pg_isready -U postgres || {
echo "❌ PostgreSQL 启动失败"
exit 1
}
# 返回 backend 目录
cd "$PROJECT_ROOT/backend"
echo "✅ PostgreSQL 已就绪"
echo ""
# 设置环境变量
export ADAPTER_MODE=production
export DATABASE_URL="postgres://postgres:postgres@localhost:5432/ocdp?sslmode=disable"
export ENCRYPTION_KEY="default-encryption-key-change-me-32"
export JWT_SECRET="your-jwt-secret-key-change-in-production"
export PORT=8080
echo "🔧 环境配置:"
echo " - ADAPTER_MODE: $ADAPTER_MODE"
echo " - DATABASE_URL: $DATABASE_URL"
echo " - PORT: $PORT"
echo ""
# 编译
echo "🔨 编译应用..."
go build -o bin/ocdp-backend cmd/api/main.go
echo "✅ 编译完成"
echo ""
# 启动应用
echo "🚀 启动 OCDP Backend (Production 模式)..."
echo ""
echo "📍 服务地址:"
echo " - API: http://localhost:8080/api/v1"
echo " - Health: http://localhost:8080/health"
echo ""
echo "📍 数据库管理:"
echo " - pgAdmin: http://localhost:5050"
echo " Email: ${PGADMIN_EMAIL:-admin@ocdp.local}"
echo " Password: ${PGADMIN_PASSWORD:-change-me}"
echo ""
echo "✨ 按 Ctrl+C 停止服务"
echo ""
./bin/ocdp-backend