build.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # Inventory Management System Docker Build Script
  3. # This script builds and deploys the complete inventory solution
  4. set -e
  5. echo "🚀 Building Inventory Management System..."
  6. # Check if Docker is installed
  7. if ! command -v docker &> /dev/null; then
  8. echo "❌ Docker is not installed. Please install Docker first."
  9. exit 1
  10. fi
  11. # Check if Docker Compose is installed
  12. if ! command -v docker-compose &> /dev/null; then
  13. echo "❌ Docker Compose is not installed. Please install Docker Compose first."
  14. exit 1
  15. fi
  16. # Check if .env file exists, if not copy from example
  17. if [ ! -f .env ]; then
  18. echo "📝 Creating .env file from .env.example..."
  19. cp .env.example .env
  20. echo "⚠️ Please edit .env file with your configuration before running the application."
  21. fi
  22. # Create uploads directory if it doesn't exist
  23. if [ ! -d uploads ]; then
  24. echo "📁 Creating uploads directory..."
  25. mkdir -p uploads
  26. chmod 755 uploads
  27. fi
  28. # Build and start the application
  29. echo "🔨 Building Docker containers..."
  30. docker-compose build
  31. echo "🚀 Starting application..."
  32. docker-compose up -d
  33. # Check if containers are running
  34. echo "🔍 Checking container status..."
  35. docker-compose ps
  36. # Show logs
  37. echo "📋 Showing application logs..."
  38. docker-compose logs inventory-app
  39. echo "✅ Build complete!"
  40. echo ""
  41. echo "🌐 Application is available at: http://localhost"
  42. echo "🔧 API endpoints are available at: http://localhost/api"
  43. echo "⚠️ Make sure your external database is accessible and configured in .env"
  44. echo ""
  45. echo "📝 To stop the application: docker-compose down"
  46. echo "📝 To view logs: docker-compose logs -f"
  47. echo "📝 To rebuild: docker-compose build --no-cache"