#!/bin/bash # Inventory Management System Docker Build Script # This script builds and deploys the complete inventory solution set -e echo "🚀 Building Inventory Management System..." # Check if Docker is installed if ! command -v docker &> /dev/null; then echo "❌ Docker is not installed. Please install Docker first." 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." exit 1 fi # Check if .env file exists, if not copy from example if [ ! -f .env ]; then echo "📝 Creating .env file from .env.example..." cp .env.example .env echo "⚠️ Please edit .env file with your configuration before running the application." fi # Create uploads directory if it doesn't exist if [ ! -d uploads ]; then echo "📁 Creating uploads directory..." mkdir -p uploads chmod 755 uploads fi # Build and start the application echo "🔨 Building Docker containers..." docker-compose build echo "🚀 Starting application..." docker-compose up -d # Wait for database to be ready echo "⏳ Waiting for database to be ready..." sleep 30 # Check if containers are running echo "🔍 Checking container status..." docker-compose ps # Show logs echo "📋 Showing application logs..." docker-compose logs inventory-app echo "✅ Build complete!" echo "" echo "🌐 Application is available at: http://localhost" echo "🔧 API endpoints are available at: http://localhost/api" echo "📊 Database is available at: localhost:3306" echo "" echo "📝 To stop the application: docker-compose down" echo "📝 To view logs: docker-compose logs -f" echo "📝 To rebuild: docker-compose build --no-cache"