-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·129 lines (108 loc) · 3.43 KB
/
setup.sh
File metadata and controls
executable file
·129 lines (108 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# hellgate Setup Script
# This script helps set up the development environment
set -e
echo "🚀 hellgate Setup Script"
echo "=========================="
echo ""
# Check prerequisites
echo "📋 Checking prerequisites..."
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed. Please install Docker first."
exit 1
fi
if ! command -v docker compose &> /dev/null; then
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
exit 1
fi
if ! command -v mvn &> /dev/null; then
echo "⚠️ Maven is not installed. You'll need it to build services manually."
fi
echo "✅ Prerequisites check complete"
echo ""
# Create necessary directories
echo "📁 Creating necessary directories..."
mkdir -p logs
mkdir -p monitoring/grafana/data
mkdir -p monitoring/prometheus/data
echo "✅ Directories created"
echo ""
# Set up environment variables
echo "🔧 Setting up environment variables..."
if [ ! -f .env ]; then
cat > .env << EOF
# JWT Secret Key (change in production!)
JWT_SECRET_KEY=change-this-secret-key-in-production-use-rsa-256-bit-minimum
# Database
POSTGRES_PASSWORD=hellgate123
# Redis
REDIS_PASSWORD=
# Kong
KONG_DATABASE_PASSWORD=kong123
EOF
echo "✅ Created .env file"
else
echo "ℹ️ .env file already exists"
fi
echo ""
# Build services
echo "🔨 Building services..."
echo "This may take a while on first run..."
# Build auth-service
if [ -d "auth-service" ]; then
echo "Building auth-service..."
cd auth-service
mvn clean package -DskipTests || echo "⚠️ Failed to build auth-service"
cd ..
fi
# Build eureka-server
if [ -d "eureka-server" ]; then
echo "Building eureka-server..."
cd eureka-server
mvn clean package -DskipTests || echo "⚠️ Failed to build eureka-server"
cd ..
fi
# Build spring-cloud-gateway
if [ -d "spring-cloud-gateway" ]; then
echo "Building spring-cloud-gateway..."
cd spring-cloud-gateway
mvn clean package -DskipTests || echo "⚠️ Failed to build spring-cloud-gateway"
cd ..
fi
echo "✅ Build complete"
echo ""
# Start services
echo "🐳 Starting Docker services..."
echo "This will start all services in the background."
read -p "Do you want to start services now? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker compose up -d
echo ""
echo "✅ Services started!"
echo ""
echo "📊 Service URLs:"
echo " - Kong Gateway: http://localhost:8000"
echo " - Kong Admin: http://localhost:8001"
echo " - Auth Service: http://localhost:8080"
echo " - Eureka Dashboard: http://localhost:8761"
echo " - Grafana: http://localhost:3000 (admin/admin)"
echo " - Prometheus: http://localhost:9090"
echo " - Kibana: http://localhost:5601"
echo ""
echo "⏳ Waiting for services to be healthy..."
sleep 10
echo ""
echo "📝 To view logs: docker compose logs -f [service-name]"
echo "📝 To stop services: docker compose down"
else
echo "ℹ️ Skipping service startup. Run 'docker compose up -d' when ready."
fi
echo ""
echo "✨ Setup complete!"
echo ""
echo "📚 Next steps:"
echo " 1. Review the README.md for detailed documentation"
echo " 2. Check service health: docker compose ps"
echo " 3. Test authentication: curl -X POST http://localhost:8080/api/auth/register -H 'Content-Type: application/json' -d '{\"username\":\"test\",\"email\":\"test@example.com\",\"password\":\"password123\"}'"
echo ""