ininventer/setup.sh

91 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# InInventer Setup Script
# This script helps set up the development environment
echo "==================================="
echo "InInventer Development Setup"
echo "==================================="
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed. Please install Docker first."
echo "Visit: https://docs.docker.com/get-docker/"
exit 1
fi
# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
echo "Visit: https://docs.docker.com/compose/install/"
exit 1
fi
echo "✅ Docker and Docker Compose are installed"
# Create .env file if it doesn't exist
if [ ! -f .env ]; then
echo ""
echo "Creating .env file from template..."
cp .env.example .env
echo "✅ Created .env file"
echo ""
echo "⚠️ IMPORTANT: Edit .env file and update the following:"
echo " - MONGO_INITDB_ROOT_USERNAME"
echo " - MONGO_INITDB_ROOT_PASSWORD"
echo " - JWT_SECRET (use: openssl rand -base64 64)"
echo " - SUPERADMIN_EMAIL"
echo " - SUPERADMIN_PASSWORD"
echo ""
read -p "Press Enter after you've updated .env file..."
else
echo "✅ .env file already exists"
fi
# Create frontend .env if it doesn't exist
if [ ! -f frontend/.env ]; then
echo "Creating frontend/.env file..."
cp frontend/.env.example frontend/.env
echo "✅ Created frontend/.env file"
else
echo "✅ frontend/.env file already exists"
fi
# Pull Docker images
echo ""
echo "Pulling Docker images..."
docker-compose pull
# Start services
echo ""
echo "Starting services..."
docker-compose up -d
# Wait for services to be ready
echo ""
echo "Waiting for services to start..."
sleep 10
# Check if services are running
if docker-compose ps | grep -q "Up"; then
echo ""
echo "==================================="
echo "✅ Setup Complete!"
echo "==================================="
echo ""
echo "Access the application at:"
echo " - Frontend: http://localhost:3000"
echo " - Backend API: http://localhost:5000"
echo " - MongoDB: localhost:27017"
echo ""
echo "Login with the credentials you set in .env:"
echo " - Email: \$SUPERADMIN_EMAIL"
echo " - Password: \$SUPERADMIN_PASSWORD"
echo ""
echo "To view logs: docker-compose logs -f"
echo "To stop: docker-compose down"
else
echo ""
echo "❌ Services failed to start. Check logs with:"
echo "docker-compose logs"
fi