-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·95 lines (81 loc) · 2.53 KB
/
setup.sh
File metadata and controls
executable file
·95 lines (81 loc) · 2.53 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
#!/bin/bash
# E-Library Setup Script
echo "🚀 Setting up E-Library Full-Stack Application..."
# Check if Docker is installed
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
# Create environment files if they don't exist
echo "📝 Creating environment files..."
if [ ! -f backend/.env ]; then
cp backend/env.example backend/.env
echo "✅ Created backend/.env from template"
else
echo "ℹ️ backend/.env already exists"
fi
if [ ! -f frontend/.env.local ]; then
cp frontend/env.example frontend/.env.local
echo "✅ Created frontend/.env.local from template"
else
echo "ℹ️ frontend/.env.local already exists"
fi
# Build and start services
echo "🐳 Building and starting Docker containers..."
docker-compose up -d --build
# Wait for services to be ready
echo "⏳ Waiting for services to be ready..."
sleep 30
# Check if services are running
echo "🔍 Checking service health..."
# Check MongoDB
if docker-compose exec -T mongodb mongosh --eval "db.runCommand('ping')" &> /dev/null; then
echo "✅ MongoDB is running"
else
echo "❌ MongoDB is not responding"
fi
# Check Backend
if curl -f http://localhost:8000/api/ &> /dev/null; then
echo "✅ Backend API is running"
else
echo "❌ Backend API is not responding"
fi
# Check Frontend
if curl -f http://localhost &> /dev/null; then
echo "✅ Frontend is running"
else
echo "❌ Frontend is not responding"
fi
# Seed the database
echo "🌱 Seeding the database with sample data..."
docker-compose exec backend python seed.py
echo ""
echo "🎉 Setup complete!"
echo ""
echo "📚 Access your E-Library:"
echo " Frontend: http://localhost"
echo " Backend API: http://localhost:8000/api"
echo " API Documentation: http://localhost:8000/api/docs"
echo ""
echo "👤 Default admin account:"
echo " Email: admin@elibrary.com"
echo " Password: password123"
echo ""
echo "👥 Sample user accounts:"
echo " Email: john.doe@example.com"
echo " Password: password123"
echo ""
echo " Email: jane.smith@example.com"
echo " Password: password123"
echo ""
echo "🛠️ Useful commands:"
echo " View logs: docker-compose logs -f"
echo " Stop services: docker-compose down"
echo " Restart services: docker-compose restart"
echo " Rebuild: docker-compose up -d --build"
echo ""
echo "📖 For more information, see README.md"