103 lines
3.5 KiB
Bash
Executable File
103 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
NAME="${APP_NAME:-glastree}"
|
|
VERSION="$(date +%Y%m%d_%H%M)"
|
|
ARCHIVE="${NAME}-${VERSION}.tar.gz"
|
|
|
|
echo "==> Installazione dipendenze PHP production..."
|
|
composer install --no-dev --optimize-autoloader --no-scripts --quiet
|
|
echo " OK"
|
|
|
|
echo "==> Build asset Vite..."
|
|
if [ -f "node_modules/.package-lock.json" ] || [ -d "node_modules" ]; then
|
|
npm run build --quiet 2>/dev/null && echo " OK" || echo " (skip — node_modules non presente)"
|
|
else
|
|
echo " (skip — node_modules assente, build Vite non eseguita)"
|
|
fi
|
|
|
|
echo "==> Pulizia cache..."
|
|
rm -rf bootstrap/cache/*.php storage/framework/cache/data/* storage/framework/sessions/* storage/framework/views/* storage/logs/* 2>/dev/null || true
|
|
echo " OK"
|
|
|
|
echo "==> Creazione archivio: ${ARCHIVE}"
|
|
|
|
tar czf "${ARCHIVE}" \
|
|
--exclude='.git' \
|
|
--exclude='.gitignore' \
|
|
--exclude='.env' \
|
|
--exclude='.env.example' \
|
|
--exclude='node_modules' \
|
|
--exclude='tests' \
|
|
--exclude='vendor/bin' \
|
|
--exclude='vendor/*/tests' \
|
|
--exclude='vendor/*/test' \
|
|
--exclude='vendor/*/.git' \
|
|
--exclude='vendor/*/docs' \
|
|
--exclude='vendor/*/doc' \
|
|
--exclude='storage/app/backups' \
|
|
--exclude='storage/app/documenti' \
|
|
--exclude='storage/app/public' \
|
|
--exclude='storage/app/private' \
|
|
--exclude='public/storage' \
|
|
--exclude='storage/framework/cache/*' \
|
|
--exclude='storage/framework/sessions/*' \
|
|
--exclude='storage/framework/views/*' \
|
|
--exclude='storage/logs/*' \
|
|
--exclude='storage/debugbar/*' \
|
|
--exclude='bootstrap/cache/*.php' \
|
|
--exclude='public/hot' \
|
|
--exclude='*.tar.gz' \
|
|
--exclude='*.tar' \
|
|
--exclude='MEMORY.md' \
|
|
--exclude='AGENTS.md' \
|
|
--exclude='build-dist.sh' \
|
|
--exclude='Dockerfile' \
|
|
--exclude='docker-compose.yml' \
|
|
--exclude='docker-compose.mysql.yml' \
|
|
--exclude='docker-entrypoint.sh' \
|
|
--exclude='.dockerignore' \
|
|
--warning=no-file-changed \
|
|
.
|
|
|
|
echo ""
|
|
echo "============================================"
|
|
echo " Archivio creato: ${ARCHIVE}"
|
|
echo " Dimensione: $(du -h "${ARCHIVE}" | cut -f1)"
|
|
echo "============================================"
|
|
echo ""
|
|
echo "Per estrarre sul server di destinazione:"
|
|
echo " tar xzf ${ARCHIVE}"
|
|
echo ""
|
|
echo "Poi esegui:"
|
|
echo " # 0. Diagnostica preliminare"
|
|
echo " php diagnose.php"
|
|
echo ""
|
|
echo " # 1. Crea directory necessarie (se non esistono già)"
|
|
echo ' mkdir -p storage/framework/cache/data storage/framework/sessions storage/framework/views storage/logs bootstrap/cache storage/app/public storage/app/public/logos storage/app/public/documenti/eventi storage/app/backups storage/app/documenti storage/app/private/avatars/gruppi'
|
|
echo ""
|
|
echo " # 2. Crea file .gitignore in storage/app/public (serve a Laravel)"
|
|
echo ' echo "*" > storage/app/public/.gitignore'
|
|
echo ' echo "!.gitignore" >> storage/app/public/.gitignore'
|
|
echo ""
|
|
echo " # 3. Permessi (web server = www-data)"
|
|
echo ' chmod -R 775 storage bootstrap/cache'
|
|
echo ' chown -R www-data:www-data storage bootstrap/cache'
|
|
echo ""
|
|
echo " # 4. Configura ambiente"
|
|
echo " cp .env.example .env # modifica DB, APP_URL, etc."
|
|
echo " php artisan key:generate"
|
|
echo ""
|
|
echo " # 5. Pulisci cache e ricrea symlink storage (relativo per portabilità)"
|
|
echo ' rm -f public/storage'
|
|
echo ' ln -sf ../storage/app/public public/storage'
|
|
echo " php artisan config:clear"
|
|
echo " php artisan route:clear"
|
|
echo " php artisan view:clear"
|
|
echo ""
|
|
echo " # 6. Avvia installazione MySQL"
|
|
echo " php install.php"
|
|
echo ""
|
|
echo " # 7. Verifica finale"
|
|
echo " php diagnose.php"
|