Files
laravel-docker-setup/docker/docker-entrypoint.sh
y9938 49b7d83dfa feat(docker): refactor to use pre-built images
- Add build/load script for image management
- Use .env config for image naming and PHP version
- Switch to www-data user in Dockerfile
- Update compose.yaml to use pre-built images
- Add .dockerignore
- Simplify entrypoint script
2025-12-10 03:06:02 +03:00

53 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
set -e
APP_ENV=${APP_ENV:-unknown}
echo ">> Running in $APP_ENV mode"
# Only for Laravel project
if [ -f "artisan" ]; then
echo ">> Ensuring composer dependencies are up to date..."
if [ "$APP_ENV" = "production" ]; then
composer install --no-dev --optimize-autoloader
else
composer install --optimize-autoloader
fi
if [ -f ".env" ] && grep -q '^APP_KEY=$' .env; then
echo ">> Generating application key..."
php artisan key:generate --ansi
fi
echo ">> Waiting for MySQL..."
while ! nc -z mysql 3306; do sleep 1; done
echo ">> Running migrations..."
php artisan migrate --force || true
if [ ! -L "public/storage" ] && [ -d "storage/app/public" ]; then
echo ">> Creating storage link..."
php artisan storage:link
fi
if [ "$APP_ENV" = "local" ]; then
echo ">> Running seeders..."
php artisan db:seed --force || true
if composer show knuckleswtf/scribe > /dev/null 2>&1; then
echo ">> Generating API documentation..."
php artisan scribe:generate --no-interaction || echo ">> Documentation generation failed, continuing..."
else
echo ">> Scribe not installed, skipping documentation generation"
fi
fi
if [ "$APP_ENV" = "production" ]; then
php artisan optimize
fi
else
echo ">> Not a Laravel project"
fi
exec "$@"