docker image to alpine, reduce size, compile scripts, entrypoint for alpine
This commit is contained in:
@@ -14,14 +14,6 @@ if [ ! -f .env.production ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create necessary directories
|
||||
echo "📁 Creating necessary directories..."
|
||||
mkdir -p data backups logs
|
||||
|
||||
# Set proper permissions
|
||||
echo "🔒 Setting directory permissions..."
|
||||
chmod 755 data backups logs
|
||||
|
||||
# Pull latest changes (if using git)
|
||||
if [ -d ".git" ]; then
|
||||
echo "📦 Pulling latest changes..."
|
||||
@@ -29,59 +21,57 @@ if [ -d ".git" ]; then
|
||||
fi
|
||||
|
||||
# Build and deploy with Docker Compose
|
||||
echo "� Building and starting Docker containers..."
|
||||
echo "🐳 Building and starting Docker containers..."
|
||||
echo "🐳 Building and deploying containers..."
|
||||
|
||||
# Stop existing containers
|
||||
docker compose -f docker-compose.production.yml down || echo "No existing containers to stop"
|
||||
|
||||
# Build and start containers
|
||||
# Build and start containers (database initialization is automated)
|
||||
docker compose -f docker-compose.production.yml up -d --build
|
||||
|
||||
# Wait for containers to be healthy
|
||||
echo "⏳ Waiting for containers to be healthy..."
|
||||
sleep 30
|
||||
|
||||
# Check health
|
||||
echo "🔍 Checking application health..."
|
||||
for i in {1..10}; do
|
||||
if curl -f http://localhost:3036/api/health >/dev/null 2>&1; then
|
||||
# Wait for health check to pass (container has built-in health checks)
|
||||
echo "⏳ Waiting for application to be ready..."
|
||||
timeout=60
|
||||
counter=0
|
||||
while [ $counter -lt $timeout ]; do
|
||||
if docker compose -f docker-compose.production.yml ps tt-booking | grep -q "healthy"; then
|
||||
echo "✅ Application is healthy!"
|
||||
break
|
||||
elif [ $i -eq 10 ]; then
|
||||
echo "❌ Application health check failed after 10 attempts"
|
||||
elif [ $counter -eq $((timeout-10)) ]; then
|
||||
echo "❌ Application failed to become healthy within ${timeout}s"
|
||||
echo "📋 Container logs:"
|
||||
docker compose -f docker-compose.production.yml logs tt-booking
|
||||
docker compose -f docker-compose.production.yml logs --tail=30 tt-booking
|
||||
exit 1
|
||||
else
|
||||
echo "⏳ Attempt $i/10: Application not ready yet, waiting..."
|
||||
sleep 10
|
||||
echo "⏳ Waiting for health check... (${counter}s/${timeout}s)"
|
||||
sleep 5
|
||||
counter=$((counter+5))
|
||||
fi
|
||||
done
|
||||
|
||||
# Show running containers
|
||||
echo "📊 Running containers:"
|
||||
docker compose -f docker-compose.production.yml ps
|
||||
# Show deployment status
|
||||
echo "📊 Deployment Status:"
|
||||
docker compose -f docker-compose.production.yml ps tt-booking
|
||||
|
||||
# Show logs
|
||||
echo "📋 Recent application logs:"
|
||||
docker compose -f docker-compose.production.yml logs --tail=20 tt-booking
|
||||
docker compose -f docker-compose.production.yml logs --tail=10 tt-booking
|
||||
|
||||
echo ""
|
||||
echo "🎉 Deployment completed successfully!"
|
||||
echo ""
|
||||
echo "📊 Application Status:"
|
||||
echo " • URL: https://lcc-tt-booking.mikicvi.com"
|
||||
echo " • Health Check: http://localhost:3036/api/health"
|
||||
echo " • Container Status: $(docker compose -f docker-compose.production.yml ps -q tt-booking | xargs docker inspect -f '{{.State.Status}}')"
|
||||
echo "📊 Application Details:"
|
||||
echo " - URL: https://lcc-tt-booking.mikicvi.com"
|
||||
echo " - Local: http://localhost:3036"
|
||||
echo " - Health: http://localhost:3036/api/health"
|
||||
echo ""
|
||||
echo "🔧 Useful commands:"
|
||||
echo " • View logs: docker compose -f docker-compose.production.yml logs -f tt-booking"
|
||||
echo " • Restart: docker compose -f docker-compose.production.yml restart tt-booking"
|
||||
echo " • Stop: docker compose -f docker-compose.production.yml down"
|
||||
echo "🔧 Management commands:"
|
||||
echo " - Logs: docker compose -f docker-compose.production.yml logs -f tt-booking"
|
||||
echo " - Restart: docker compose -f docker-compose.production.yml restart tt-booking"
|
||||
echo " - Stop: docker compose -f docker-compose.production.yml down"
|
||||
echo " - Shell: docker compose -f docker-compose.production.yml exec tt-booking sh"
|
||||
echo ""
|
||||
echo "⚠️ Don't forget to:"
|
||||
echo " 1. Set up Cloudflare Tunnel to expose your application"
|
||||
echo " 2. Update your .env.production with real email credentials"
|
||||
echo " 3. Change the default admin password"
|
||||
echo "⚠️ Post-deployment checklist:"
|
||||
echo " - Cloudflare Tunnel is configured and running"
|
||||
echo " - Admin password changed from default"
|
||||
echo " - Email settings configured in .env.production"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user