Primo commit
This commit is contained in:
93
docker/php/entrypoint.sh
Executable file
93
docker/php/entrypoint.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "========================================="
|
||||
echo " TerManager2 - Entrypoint"
|
||||
echo "========================================="
|
||||
|
||||
# -----------------------------------------------
|
||||
# 1. Composer install
|
||||
# -----------------------------------------------
|
||||
if [ ! -f vendor/autoload.php ]; then
|
||||
echo "[*] Installing Composer dependencies..."
|
||||
composer install --no-interaction --optimize-autoloader
|
||||
else
|
||||
echo "[✓] Composer dependencies already installed."
|
||||
fi
|
||||
|
||||
# -----------------------------------------------
|
||||
# 2. .env file
|
||||
# -----------------------------------------------
|
||||
if [ ! -f .env ]; then
|
||||
echo "[*] Creating .env from .env.example..."
|
||||
cp .env.example .env
|
||||
else
|
||||
echo "[✓] .env file already exists."
|
||||
fi
|
||||
|
||||
# -----------------------------------------------
|
||||
# 3. Application key
|
||||
# -----------------------------------------------
|
||||
if grep -q "^APP_KEY=$" .env; then
|
||||
echo "[*] Generating application key..."
|
||||
php artisan key:generate --ansi
|
||||
else
|
||||
echo "[✓] Application key already set."
|
||||
fi
|
||||
|
||||
# -----------------------------------------------
|
||||
# 4. NPM install & build assets
|
||||
# -----------------------------------------------
|
||||
if [ ! -d node_modules ]; then
|
||||
echo "[*] Installing NPM dependencies..."
|
||||
npm ci
|
||||
else
|
||||
echo "[✓] NPM dependencies already installed."
|
||||
fi
|
||||
|
||||
if [ ! -d public/build ]; then
|
||||
echo "[*] Building frontend assets..."
|
||||
npm run build
|
||||
else
|
||||
echo "[✓] Frontend assets already built."
|
||||
fi
|
||||
|
||||
# -----------------------------------------------
|
||||
# 5. Storage link
|
||||
# -----------------------------------------------
|
||||
if [ ! -L public/storage ]; then
|
||||
echo "[*] Creating storage symlink..."
|
||||
php artisan storage:link
|
||||
else
|
||||
echo "[✓] Storage symlink already exists."
|
||||
fi
|
||||
|
||||
# -----------------------------------------------
|
||||
# 6. Create required storage directories
|
||||
# -----------------------------------------------
|
||||
mkdir -p storage/framework/{cache,sessions,views}
|
||||
mkdir -p storage/logs
|
||||
mkdir -p bootstrap/cache
|
||||
|
||||
# -----------------------------------------------
|
||||
# 7. Run migrations
|
||||
# -----------------------------------------------
|
||||
echo "[*] Running database migrations..."
|
||||
php artisan migrate --force
|
||||
|
||||
# -----------------------------------------------
|
||||
# 8. Cache config/routes/views
|
||||
# -----------------------------------------------
|
||||
echo "[*] Caching configuration..."
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
|
||||
echo "========================================="
|
||||
echo " TerManager2 - Ready!"
|
||||
echo "========================================="
|
||||
|
||||
# -----------------------------------------------
|
||||
# Execute CMD (default: php-fpm)
|
||||
# -----------------------------------------------
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user