Some checks failed
Deploy / deploy (push) Has been cancelled
Full-stack web application for Telegram management - Frontend: Vue 3 + Vben Admin - Backend: NestJS - Features: User management, group broadcast, statistics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
175 lines
4.0 KiB
Bash
Executable File
175 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
# Marketing Intelligence Agent Deployment Script
|
||
|
||
set -e
|
||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
|
||
|
||
# Colors for output
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
NC='\033[0m' # No Color
|
||
|
||
# Functions
|
||
print_success() {
|
||
echo -e "${GREEN}✓ $1${NC}"
|
||
}
|
||
|
||
print_error() {
|
||
echo -e "${RED}✗ $1${NC}"
|
||
}
|
||
|
||
print_info() {
|
||
echo -e "${YELLOW}ℹ $1${NC}"
|
||
}
|
||
|
||
# Check prerequisites
|
||
check_prerequisites() {
|
||
print_info "Checking prerequisites..."
|
||
|
||
# Check Docker
|
||
if ! command -v docker &> /dev/null; then
|
||
print_error "Docker is not installed"
|
||
exit 1
|
||
fi
|
||
print_success "Docker found"
|
||
|
||
# Check Docker Compose
|
||
if ! command -v docker-compose &> /dev/null; then
|
||
print_error "Docker Compose is not installed"
|
||
exit 1
|
||
fi
|
||
print_success "Docker Compose found"
|
||
|
||
# Check kubectl (optional)
|
||
if command -v kubectl &> /dev/null; then
|
||
print_success "kubectl found (optional)"
|
||
else
|
||
print_info "kubectl not found (optional for Kubernetes deployment)"
|
||
fi
|
||
}
|
||
|
||
# Build Docker images
|
||
build_images() {
|
||
print_info "Building Docker images..."
|
||
|
||
cd "$PROJECT_ROOT"
|
||
|
||
# Build all services
|
||
docker-compose build --parallel
|
||
|
||
print_success "Docker images built successfully"
|
||
}
|
||
|
||
# Start infrastructure services
|
||
start_infrastructure() {
|
||
print_info "Starting infrastructure services..."
|
||
|
||
cd "$PROJECT_ROOT"
|
||
|
||
# Start databases and message queues
|
||
docker-compose up -d postgres mongodb redis rabbitmq elasticsearch
|
||
|
||
# Wait for services to be ready
|
||
print_info "Waiting for databases to be ready..."
|
||
sleep 30
|
||
|
||
print_success "Infrastructure services started"
|
||
}
|
||
|
||
# Run database migrations
|
||
run_migrations() {
|
||
print_info "Running database migrations..."
|
||
|
||
# TODO: Add migration scripts here
|
||
|
||
print_success "Database migrations completed"
|
||
}
|
||
|
||
# Start application services
|
||
start_services() {
|
||
print_info "Starting application services..."
|
||
|
||
cd "$PROJECT_ROOT"
|
||
|
||
# Start all services
|
||
docker-compose up -d
|
||
|
||
print_success "All services started"
|
||
}
|
||
|
||
# Check service health
|
||
check_health() {
|
||
print_info "Checking service health..."
|
||
|
||
# Wait for services to start
|
||
sleep 10
|
||
|
||
# Check each service
|
||
services=("orchestrator" "claude-agent" "gramjs-adapter" "safety-guard" "analytics" "ab-testing")
|
||
|
||
for service in "${services[@]}"; do
|
||
if docker-compose ps | grep -q "$service.*Up"; then
|
||
print_success "$service is running"
|
||
else
|
||
print_error "$service is not running"
|
||
fi
|
||
done
|
||
}
|
||
|
||
# Deploy to Kubernetes (optional)
|
||
deploy_kubernetes() {
|
||
print_info "Deploying to Kubernetes..."
|
||
|
||
if ! command -v kubectl &> /dev/null; then
|
||
print_error "kubectl is not installed, skipping Kubernetes deployment"
|
||
return
|
||
fi
|
||
|
||
cd "$PROJECT_ROOT/infrastructure/k8s"
|
||
|
||
# Apply Kubernetes manifests
|
||
kubectl apply -f namespace.yaml
|
||
kubectl apply -f configmap.yaml
|
||
kubectl apply -f secrets.yaml
|
||
|
||
print_success "Kubernetes deployment completed"
|
||
}
|
||
|
||
# Main deployment flow
|
||
main() {
|
||
print_info "Starting Marketing Intelligence Agent deployment..."
|
||
|
||
# Check prerequisites
|
||
check_prerequisites
|
||
|
||
# Parse command line arguments
|
||
case "${1:-docker}" in
|
||
docker)
|
||
build_images
|
||
start_infrastructure
|
||
run_migrations
|
||
start_services
|
||
check_health
|
||
;;
|
||
k8s|kubernetes)
|
||
deploy_kubernetes
|
||
;;
|
||
*)
|
||
print_error "Unknown deployment target: $1"
|
||
echo "Usage: $0 [docker|k8s]"
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
print_success "Deployment completed successfully!"
|
||
print_info "Access the API at: http://localhost:8000"
|
||
print_info "Access Grafana at: http://localhost:3000 (admin/admin)"
|
||
print_info "Access RabbitMQ at: http://localhost:15672 (admin/admin)"
|
||
}
|
||
|
||
# Run main function
|
||
main "$@" |