Files
ColaFlow/scripts/dev-start.sh
Yaojia Wang 8c0e6e8c23 feat(docker): Add Phase 4 - automated startup scripts and documentation
Implemented one-click development environment startup solution for frontend developers.

Changes:
- Created scripts/dev-start.ps1 (PowerShell startup script for Windows)
  * Docker health checks
  * Service status monitoring
  * Clean/Logs/Stop command options
  * Auto .env creation from .env.example
  * Friendly colored output and progress indicators

- Created scripts/dev-start.sh (Bash startup script for Linux/macOS)
  * Feature parity with PowerShell version
  * Cross-platform compatibility
  * Color-coded status messages

- Updated .env.example with comprehensive configuration
  * Added missing port configurations
  * Added JWT settings (Issuer, Audience)
  * Added SignalR hub URL
  * Improved documentation and organization

- Created README.md (project documentation)
  * Quick start guide for Docker setup
  * Manual development instructions
  * Project structure overview
  * Technology stack details
  * Troubleshooting guide
  * Development workflow

Testing:
- Verified PowerShell script syntax (valid)
- Verified Bash script has executable permissions
- Confirmed all files created successfully
- Docker services running and healthy

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 23:50:55 +01:00

149 lines
3.4 KiB
Bash

#!/bin/bash
# ColaFlow 开发环境启动脚本 (Bash)
set -e
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# 输出函数
success() { echo -e "${GREEN}$1${NC}"; }
info() { echo -e "${CYAN}$1${NC}"; }
warning() { echo -e "${YELLOW}$1${NC}"; }
error() { echo -e "${RED}$1${NC}"; }
# 横幅
info "
╔═══════════════════════════════════════════╗
║ ColaFlow Development Environment ║
║ Docker-based Development Stack ║
╚═══════════════════════════════════════════╝
"
# 检查 Docker
info "🔍 Checking Docker..."
if ! command -v docker &> /dev/null; then
error "❌ Docker not found! Please install Docker."
exit 1
fi
if ! docker info &> /dev/null; then
error "❌ Docker is not running! Please start Docker."
exit 1
fi
success "✅ Docker is ready"
# 参数处理
CLEAN=false
LOGS=false
STOP=false
while [[ $# -gt 0 ]]; do
case $1 in
--clean|-c)
CLEAN=true
shift
;;
--logs|-l)
LOGS=true
shift
;;
--stop|-s)
STOP=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--clean] [--logs] [--stop]"
exit 1
;;
esac
done
# 停止服务
if [ "$STOP" = true ]; then
info "🛑 Stopping all services..."
docker-compose down
success "✅ All services stopped"
exit 0
fi
# 查看日志
if [ "$LOGS" = true ]; then
info "📋 Showing logs (Ctrl+C to exit)..."
docker-compose logs -f
exit 0
fi
# 清理
if [ "$CLEAN" = true ]; then
warning "🧹 Cleaning up containers and volumes..."
docker-compose down -v
info "🔨 Rebuilding images..."
docker-compose build --no-cache
fi
# 检查 .env 文件
if [ ! -f ".env" ]; then
if [ -f ".env.example" ]; then
info "📄 Creating .env from .env.example..."
cp .env.example .env
success "✅ .env file created"
else
warning "⚠️ No .env or .env.example found, using docker-compose defaults"
fi
fi
# 启动服务
info "🚀 Starting services..."
docker-compose up -d
# 等待健康检查
info "⏳ Waiting for services to be healthy..."
max_wait=60
waited=0
interval=2
while [ $waited -lt $max_wait ]; do
if docker-compose ps | grep -q "unhealthy"; then
sleep $interval
waited=$((waited + interval))
echo -n "."
else
break
fi
done
echo ""
# 检查服务状态
info "\n📊 Service Status:"
docker-compose ps
success "\n🎉 ColaFlow development environment is ready!"
info "
📍 Access Points:
Frontend: http://localhost:3000
Backend: http://localhost:5000
Swagger: http://localhost:5000/scalar/v1
Database: localhost:5432 (colaflow/colaflow_dev_password)
Redis: localhost:6379
👤 Demo Accounts (see scripts/DEMO-ACCOUNTS.md):
Owner: owner@demo.com / Demo@123456
Developer: developer@demo.com / Demo@123456
📝 Useful Commands:
./scripts/dev-start.sh --stop # Stop all services
./scripts/dev-start.sh --logs # View logs
./scripts/dev-start.sh --clean # Clean rebuild
docker-compose ps # Check status
"