-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·99 lines (86 loc) · 2.75 KB
/
setup.sh
File metadata and controls
executable file
·99 lines (86 loc) · 2.75 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
#!/bin/bash
set -e # Exit on error
echo "🚀 Fastify Gold Standard Starter Setup"
echo "======================================="
echo ""
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
echo "❌ Node.js is not installed. Please install Node.js 18+"
exit 1
fi
# Check Node.js version
NODE_VERSION=$(node -v | cut -d 'v' -f 2 | cut -d '.' -f 1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo "❌ Node.js version must be 18 or higher. Current version: $(node -v)"
exit 1
fi
if [ "$NODE_VERSION" -ge 22 ]; then
echo "⚠️ Warning: Node.js $(node -v) detected. Recommended: Node 18-20 LTS"
echo " Some dependencies may show warnings with Node 22+"
echo " Consider using: nvm use 20"
echo ""
fi
echo "✅ Node.js version: $(node -v)"
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "⚠️ Docker is not installed. You'll need it for PostgreSQL, Prometheus, and Grafana"
else
echo "✅ Docker is installed"
fi
# Copy .env.example to .env if it doesn't exist
if [ ! -f .env ]; then
echo ""
echo "📝 Creating .env file from .env.example..."
cp .env.example .env
echo "✅ .env file created (you can customize it later)"
else
echo "✅ .env file already exists"
fi
# Install dependencies
echo ""
echo "📦 Installing dependencies..."
npm install
# Generate Prisma client
echo ""
echo "🔧 Generating Prisma client..."
npx prisma generate
# Start Docker services if Docker is available
if command -v docker &> /dev/null; then
echo ""
echo "🐳 Starting Docker services (PostgreSQL, Prometheus, Grafana)..."
npm run docker:up
# Wait for PostgreSQL to be ready
echo "⏳ Waiting for PostgreSQL to be ready..."
sleep 8
# Run database migrations
echo ""
echo "🗄️ Running database migrations..."
npm run db:migrate
# Generate Grafana dashboards
echo ""
echo "📊 Generating Grafana dashboards..."
npm run generate:dashboards || echo "⚠️ No orchestrators found yet (this is normal for a fresh install)"
fi
echo ""
echo "✨ Setup complete!"
echo ""
echo "🎯 Your Fastify Gold Standard Starter is ready!"
echo ""
echo "🚀 Next steps:"
echo ""
echo " # Start everything (like DriftOS!):"
echo " make up"
echo ""
echo " # Then in another terminal:"
echo " make dev"
echo ""
echo " # Open Grafana:"
echo " make grafana"
echo ""
echo "📍 Your services will be at:"
echo " • API: http://localhost:${PORT:-3000}"
echo " • Swagger: http://localhost:${PORT:-3000}/documentation"
echo " • Prometheus: http://localhost:${PROMETHEUS_PORT:-9091}"
echo " • Grafana: http://localhost:${GRAFANA_PORT:-3010} (System Overview + Service Dashboards)"
echo ""
echo "Happy coding! 🎉"