110 lines
2.9 KiB
Bash
110 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Unified Docker Compose Setup Script
|
|
# This script helps set up the unified Docker Compose environment
|
|
|
|
set -e
|
|
|
|
echo "🚀 Setting up Unified Docker Compose Environment"
|
|
|
|
# Function to check if Docker is running
|
|
check_docker() {
|
|
if ! docker info > /dev/null 2>&1; then
|
|
echo "❌ Docker is not running. Please start Docker and try again."
|
|
exit 1
|
|
fi
|
|
echo "✅ Docker is running"
|
|
}
|
|
|
|
# Function to stop existing individual services
|
|
stop_individual_services() {
|
|
echo "🛑 Stopping individual Docker Compose services..."
|
|
|
|
if [ -f "backend/docker-compose.yml" ]; then
|
|
echo "Stopping backend services..."
|
|
cd backend && docker-compose down 2>/dev/null || true && cd ..
|
|
fi
|
|
|
|
if [ -f "frontend/docker-compose.yml" ]; then
|
|
echo "Stopping frontend services..."
|
|
cd frontend && docker-compose down 2>/dev/null || true && cd ..
|
|
fi
|
|
|
|
if [ -f "mineru/docker-compose.yml" ]; then
|
|
echo "Stopping mineru services..."
|
|
cd mineru && docker-compose down 2>/dev/null || true && cd ..
|
|
fi
|
|
|
|
echo "✅ Individual services stopped"
|
|
}
|
|
|
|
# Function to create necessary directories
|
|
create_directories() {
|
|
echo "📁 Creating necessary directories..."
|
|
|
|
mkdir -p backend/storage
|
|
mkdir -p mineru/storage/uploads
|
|
mkdir -p mineru/storage/processed
|
|
|
|
echo "✅ Directories created"
|
|
}
|
|
|
|
# Function to check if unified docker-compose.yml exists
|
|
check_unified_compose() {
|
|
if [ ! -f "docker-compose.yml" ]; then
|
|
echo "❌ Unified docker-compose.yml not found in current directory"
|
|
echo "Please run this script from the project root directory"
|
|
exit 1
|
|
fi
|
|
echo "✅ Unified docker-compose.yml found"
|
|
}
|
|
|
|
# Function to build and start services
|
|
start_unified_services() {
|
|
echo "🔨 Building and starting unified services..."
|
|
|
|
# Build all services
|
|
docker-compose build
|
|
|
|
# Start services
|
|
docker-compose up -d
|
|
|
|
echo "✅ Unified services started"
|
|
}
|
|
|
|
# Function to check service status
|
|
check_service_status() {
|
|
echo "📊 Checking service status..."
|
|
|
|
docker-compose ps
|
|
|
|
echo ""
|
|
echo "🌐 Service URLs:"
|
|
echo "Frontend: http://localhost:3000"
|
|
echo "Backend API: http://localhost:8000"
|
|
echo "Mineru API: http://localhost:8001"
|
|
echo ""
|
|
echo "📝 To view logs: docker-compose logs -f [service-name]"
|
|
echo "📝 To stop services: docker-compose down"
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
echo "=========================================="
|
|
echo "Unified Docker Compose Setup"
|
|
echo "=========================================="
|
|
|
|
check_docker
|
|
check_unified_compose
|
|
stop_individual_services
|
|
create_directories
|
|
start_unified_services
|
|
check_service_status
|
|
|
|
echo ""
|
|
echo "🎉 Setup complete! Your unified Docker environment is ready."
|
|
echo "Check the DOCKER_COMPOSE_README.md for more information."
|
|
}
|
|
|
|
# Run main function
|
|
main "$@" |