61 lines
1.5 KiB
Bash
61 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
# Production deployment script for SmartSolTech
|
|
|
|
set -e
|
|
|
|
echo "🚀 Starting SmartSolTech deployment..."
|
|
|
|
# Check if .env file exists
|
|
if [ ! -f .env ]; then
|
|
echo "⚠️ .env file not found!"
|
|
echo "Creating .env from .env.example..."
|
|
cp .env.example .env
|
|
echo "📝 Please edit .env file with your production values before continuing."
|
|
exit 1
|
|
fi
|
|
|
|
# Stop existing containers
|
|
echo "🛑 Stopping existing containers..."
|
|
docker-compose down
|
|
|
|
# Build images
|
|
echo "🏗️ Building Docker images..."
|
|
docker-compose build --no-cache
|
|
|
|
# Start services
|
|
echo "▶️ Starting services..."
|
|
docker-compose up -d postgres_db
|
|
|
|
# Wait for database to be ready
|
|
echo "⏳ Waiting for database to be ready..."
|
|
sleep 10
|
|
|
|
# Run migrations
|
|
echo "🔄 Running database migrations..."
|
|
docker-compose run --rm web python smartsoltech/manage.py migrate
|
|
|
|
# Collect static files
|
|
echo "📦 Collecting static files..."
|
|
docker-compose run --rm web python smartsoltech/manage.py collectstatic --noinput
|
|
|
|
# Create superuser (optional, commented out for security)
|
|
# echo "👤 Creating superuser..."
|
|
# docker-compose run --rm web python smartsoltech/manage.py createsuperuser
|
|
|
|
# Start all services
|
|
echo "🎬 Starting all services..."
|
|
docker-compose up -d
|
|
|
|
# Show running containers
|
|
echo "✅ Deployment complete! Running containers:"
|
|
docker-compose ps
|
|
|
|
echo ""
|
|
echo "📋 Service URLs:"
|
|
echo " Django App: http://localhost:8000"
|
|
echo " PgAdmin: http://localhost:8080"
|
|
echo ""
|
|
echo "📝 To view logs: docker-compose logs -f"
|
|
echo "🛑 To stop: docker-compose down"
|