#!/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/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 " cp .env.example .env # configura il tuo ambiente" echo " php artisan key:generate" echo " php artisan storage:link" echo " php install.php # avvia installazione MySQL"