Update deployment script to use npm commands for builds

Modify deploy.sh to utilize `npm run build` and `npm run db:push` for frontend builds and database migrations, and simplify PM2 process management.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 42d8028a-fa71-4ec2-938c-e43eedf7df01
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/42d8028a-fa71-4ec2-938c-e43eedf7df01/AwjfjCW
This commit is contained in:
marco370 2025-10-16 15:38:12 +00:00
parent 12e1efaa3d
commit 7c9ba798ed

View File

@ -58,11 +58,11 @@ npm ci
# Build frontend # Build frontend
echo "🏗️ Build frontend Vite..." echo "🏗️ Build frontend Vite..."
export NODE_ENV=production export NODE_ENV=production
./node_modules/.bin/vite build && ./node_modules/.bin/esbuild server/index.ts --platform=node --packages=external --bundle --format=esm --outdir=dist npm run build
# Database migrations (serve Drizzle che è devDependency) # Database migrations (serve Drizzle che è devDependency)
echo "🗄️ Verifica database schema..." echo "🗄️ Verifica database schema..."
./node_modules/.bin/drizzle-kit push --force || echo "⚠️ Schema push skipped (database già aggiornato)" npm run db:push || echo "⚠️ Schema push skipped (database già aggiornato)"
# NOTA: NON facciamo npm prune perché Vite serve a runtime per il middleware # NOTA: NON facciamo npm prune perché Vite serve a runtime per il middleware
# Il server Express usa Vite per servire il frontend anche in produzione # Il server Express usa Vite per servire il frontend anche in produzione
@ -91,12 +91,8 @@ if $PM2_CMD show $APP_NAME > /dev/null 2>&1; then
$PM2_CMD delete $APP_NAME $PM2_CMD delete $APP_NAME
fi fi
# Usa ecosystem.config.js se esiste, altrimenti comando diretto # Start con comando diretto (più affidabile)
if [ -f ecosystem.config.js ]; then
$PM2_CMD start ecosystem.config.js
else
$PM2_CMD start npm --name $APP_NAME -- start $PM2_CMD start npm --name $APP_NAME -- start
fi
$PM2_CMD save $PM2_CMD save
# Health check # Health check