99 lines
2.3 KiB
Bash
Executable File
99 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# QR Code Manager - Docker Build and Test Script
|
|
|
|
set -e # Exit on any error
|
|
|
|
echo "🐳 QR Code Manager - Docker Build & Test"
|
|
echo "========================================"
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Function to print colored output
|
|
print_status() {
|
|
echo -e "${GREEN}✅ $1${NC}"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}⚠️ $1${NC}"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}❌ $1${NC}"
|
|
}
|
|
|
|
# Check prerequisites
|
|
echo "🔍 Checking prerequisites..."
|
|
|
|
if ! command -v docker &> /dev/null; then
|
|
print_error "Docker is not installed"
|
|
exit 1
|
|
fi
|
|
|
|
if ! docker compose version &> /dev/null; then
|
|
print_error "Docker Compose is not available"
|
|
exit 1
|
|
fi
|
|
|
|
print_status "Docker and Docker Compose are available"
|
|
|
|
# Create environment file if it doesn't exist
|
|
if [ ! -f .env ]; then
|
|
print_warning "Creating .env file from template"
|
|
cp .env.example .env
|
|
print_warning "Please review and update .env file with secure credentials!"
|
|
fi
|
|
|
|
# Build the Docker image
|
|
echo "🏗️ Building Docker image..."
|
|
if docker compose build; then
|
|
print_status "Docker image built successfully"
|
|
else
|
|
print_error "Docker build failed"
|
|
exit 1
|
|
fi
|
|
|
|
# Start the application
|
|
echo "🚀 Starting application..."
|
|
if docker compose up -d; then
|
|
print_status "Application started successfully"
|
|
else
|
|
print_error "Failed to start application"
|
|
exit 1
|
|
fi
|
|
|
|
# Wait for application to be ready
|
|
echo "⏳ Waiting for application to be ready..."
|
|
sleep 10
|
|
|
|
# Check if application is responding
|
|
if curl -f http://localhost:5000/health > /dev/null 2>&1; then
|
|
print_status "Application is healthy and responding"
|
|
else
|
|
print_warning "Health check failed, checking logs..."
|
|
docker compose logs qr-manager
|
|
fi
|
|
|
|
# Show status
|
|
echo "📊 Application Status:"
|
|
docker compose ps
|
|
|
|
echo ""
|
|
echo "🎉 Deployment Complete!"
|
|
echo "========================================"
|
|
echo "Application URL: http://localhost:5000"
|
|
echo "Default Login:"
|
|
echo " Username: admin"
|
|
echo " Password: admin123"
|
|
echo ""
|
|
echo "Management Commands:"
|
|
echo " View logs: docker compose logs -f"
|
|
echo " Stop app: docker compose down"
|
|
echo " Restart: docker compose restart"
|
|
echo ""
|
|
print_warning "Remember to change default credentials in production!"
|