fedi-feed-router/docker/dev/podman/start-dev.sh

81 lines
3 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Podman development environment startup script for FFR
set -e
echo "🚀 Starting FFR development environment with Podman..."
# Check if .env exists
if [ ! -f .env ]; then
echo "📋 Creating .env file from .env.example..."
cp .env.example .env
fi
# Check if podman-compose is available
if ! command -v podman-compose &> /dev/null; then
echo "❌ podman-compose not found."
exit
fi
# Start services
echo "🔧 Starting services..."
podman-compose -f docker/dev/podman/docker-compose.yml up -d
# Wait for database to be ready
echo "⏳ Waiting for database to be ready..."
sleep 10
# Install/update dependencies if needed
echo "📦 Installing dependencies..."
podman exec ffr-dev-app bash -c "cd /var/www/html/backend && composer install"
podman exec ffr-dev-app bash -c "cd /var/www/html/frontend && npm install"
# Run migrations and seeders
echo "🗃️ Running database migrations..."
podman exec ffr-dev-app bash -c "cd /var/www/html/backend && php artisan migrate --force"
echo "🌱 Running database seeders..."
podman exec ffr-dev-app bash -c "cd /var/www/html/backend && php artisan db:seed --force"
# Wait for container services to be fully ready
echo "⏳ Waiting for container services to initialize..."
sleep 5
# Start React dev server if not already running
echo "🚀 Starting React dev server..."
podman exec -d ffr-dev-app bash -c "cd /var/www/html/frontend && npm run dev -- --host 0.0.0.0 --port 5173 > /dev/null 2>&1 &"
sleep 5
# Verify Vite is running
if podman exec ffr-dev-app bash -c "curl -s http://localhost:5173 > /dev/null 2>&1"; then
echo "✅ Vite dev server is running"
else
echo "⚠️ Vite dev server may not have started properly"
fi
# Check Laravel Horizon status inside the app container
echo "🔍 Checking Laravel Horizon in app container..."
HSTATUS="$(podman exec ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon:status" 2>/dev/null || echo "Horizon status: unknown")"
echo "$HSTATUS"
if echo "$HSTATUS" | grep -qi 'inactive'; then
echo " Horizon is inactive. Attempting to start..."
podman exec -d ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon > /dev/null 2>&1 &" || true
sleep 2
podman exec ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon:status" || true
else
echo "✅ Horizon appears to be running."
fi
# Show supervisors summary (non-fatal if unavailable)
podman exec ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon:supervisors | sed -n '1,80p'" || true
echo "✅ Development environment is ready!"
echo "🌐 Application: http://localhost:8000"
echo "🔥 Vite dev server: http://localhost:5173"
echo "💾 Database: localhost:3307"
echo "🔴 Redis: localhost:6380"
echo ""
echo "📋 Useful commands:"
echo " Stop: podman-compose -f docker/dev/podman/docker-compose.yml down"
echo " Logs: podman-compose -f docker/dev/podman/docker-compose.yml logs -f"
echo " Exec: podman exec -it ffr-dev-app bash"
echo " Tests: podman exec ffr-dev-app php artisan test"