incr/docker/dev/container-start.sh

33 lines
970 B
Bash
Raw Normal View History

2025-08-01 00:03:50 +02:00
#!/bin/bash
set -e
2025-08-01 00:03:50 +02:00
# Create .env file if it doesn't exist
if [ ! -f /var/www/html/.env ]; then
cp /var/www/html/.env.example /var/www/html/.env 2>/dev/null || touch /var/www/html/.env
fi
# Fix database name to match compose file
sed -i 's|^DB_DATABASE=.*|DB_DATABASE=incr_dev|' /var/www/html/.env
2025-08-01 00:03:50 +02:00
# Generate app key if not set or empty
if ! grep -q "APP_KEY=base64:" /var/www/html/.env; then
# Generate a new key and set it directly
NEW_KEY=$(php -r "echo 'base64:' . base64_encode(random_bytes(32));")
sed -i "s|^APP_KEY=.*|APP_KEY=$NEW_KEY|" /var/www/html/.env
2025-08-01 00:03:50 +02:00
fi
# Install dependencies if needed
[ ! -f vendor/autoload.php ] && composer install --no-interaction
[ ! -d node_modules/.bin ] && npm install
2025-08-01 00:03:50 +02:00
# Run migrations
php artisan migrate --force
# Start Laravel development server in background
php artisan serve --host=0.0.0.0 --port=8000 &
# Start Vite development server
npm run dev -- --host 0.0.0.0
# Wait for background processes
wait