forked from LeeMangold/OpenGRC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
52 lines (43 loc) · 1.48 KB
/
docker-entrypoint.sh
File metadata and controls
52 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -e
echo "Starting OpenGRC container..."
# Wait for database to be ready (if using external database)
if [ -n "$DB_HOST" ]; then
echo "Waiting for database connection..."
max_attempts=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
if php artisan tinker --execute="try { DB::connection()->getPdo(); echo 'ok'; } catch (\Exception \$e) { exit(1); }" 2>/dev/null | grep -q "ok"; then
echo "Database connected."
break
fi
attempt=$((attempt + 1))
echo "Waiting for database... (attempt $attempt/$max_attempts)"
sleep 2
done
if [ $attempt -eq $max_attempts ]; then
echo "Warning: Could not connect to database after $max_attempts attempts. Continuing anyway..."
fi
fi
# Run database migrations
echo "Running database migrations..."
php artisan migrate --force
# Clear and cache config for production
echo "Caching configuration..."
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Ensure storage directories have correct permissions
chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
# Create PHP-FPM run directory if it doesn't exist
mkdir -p /run/php
# Start cron daemon
echo "Starting cron..."
service cron start
# Start PHP-FPM
echo "Starting PHP-FPM..."
service php8.3-fpm start
# Start Apache in foreground
echo "Starting Apache..."
exec apache2ctl -D FOREGROUND