try deploy fix
This commit is contained in:
@ -120,6 +120,27 @@ if [ "$UPDATE_CODE_FROM_GIT" = "true" ]; then
|
|||||||
echo "Installing bcrypt package separately with build from source..." | tee -a /app/logs/deploy.txt
|
echo "Installing bcrypt package separately with build from source..." | tee -a /app/logs/deploy.txt
|
||||||
npm install bcrypt@latest --build-from-source --no-save --no-audit --no-fund || echo "Failed to install bcrypt, continuing anyway"
|
npm install bcrypt@latest --build-from-source --no-save --no-audit --no-fund || echo "Failed to install bcrypt, continuing anyway"
|
||||||
|
|
||||||
|
# Fix Prisma-specific issues
|
||||||
|
echo "Fixing Prisma-specific dependencies..." | tee -a /app/logs/deploy.txt
|
||||||
|
|
||||||
|
# Remove problematic Prisma nested dependencies
|
||||||
|
if [ -d "node_modules/@prisma" ]; then
|
||||||
|
echo "Cleaning up Prisma dependencies..." | tee -a /app/logs/deploy.txt
|
||||||
|
rm -rf node_modules/@prisma/internals/node_modules/@prisma/engines
|
||||||
|
rm -rf node_modules/@prisma/internals/node_modules/@prisma/engines-version
|
||||||
|
rm -rf node_modules/@prisma/client/node_modules/@prisma/engines-version
|
||||||
|
rm -rf node_modules/.prisma
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install specific Prisma versions known to work
|
||||||
|
echo "Installing specific Prisma versions..." | tee -a /app/logs/deploy.txt
|
||||||
|
npm uninstall prisma @prisma/client --no-save || true
|
||||||
|
npm install prisma@5.12.0 @prisma/client@5.12.0 --save-exact --no-audit --no-fund || echo "Failed to install Prisma, continuing anyway"
|
||||||
|
|
||||||
|
# Ensure Prisma engines are downloaded
|
||||||
|
echo "Generating Prisma client..." | tee -a /app/logs/deploy.txt
|
||||||
|
npx prisma generate --schema=./prisma/schema.prisma || echo "Failed to generate Prisma client, continuing anyway"
|
||||||
|
|
||||||
echo "\r\n\r\n Checking for changes in package files..."
|
echo "\r\n\r\n Checking for changes in package files..."
|
||||||
# Determine if package.json or package-lock.json has changed
|
# Determine if package.json or package-lock.json has changed
|
||||||
PACKAGE_CHANGE=0
|
PACKAGE_CHANGE=0
|
||||||
|
@ -1,72 +1,72 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script to fix npm installation issues in a running container
|
# Fix npm and Prisma dependency issues
|
||||||
# Run this script inside the container if you encounter npm package problems
|
# Run this script when connected to the container to resolve installation problems
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "====================================================="
|
LOG_FILE="/app/logs/npm-fix.log"
|
||||||
echo "Running npm dependency fix script"
|
echo "[$(date)] Starting npm fix script" | tee -a $LOG_FILE
|
||||||
echo "====================================================="
|
|
||||||
|
|
||||||
# Navigate to app directory
|
# Navigate to app directory
|
||||||
cd /app
|
cd /app
|
||||||
|
echo "[$(date)] Working in directory: $(pwd)" | tee -a $LOG_FILE
|
||||||
|
|
||||||
# Create logs directory if it doesn't exist
|
# Clean up problematic packages
|
||||||
mkdir -p /app/logs
|
echo "[$(date)] Removing problematic packages..." | tee -a $LOG_FILE
|
||||||
LOG_FILE="/app/logs/npm-fix.log"
|
rm -rf node_modules/abbrev 2>/dev/null || true
|
||||||
|
rm -rf node_modules/bcrypt 2>/dev/null || true
|
||||||
|
rm -rf node_modules/.prisma 2>/dev/null || true
|
||||||
|
|
||||||
echo "Starting npm fix at $(date)" > "$LOG_FILE"
|
# Clean up Prisma nested modules
|
||||||
|
echo "[$(date)] Cleaning up Prisma dependencies..." | tee -a $LOG_FILE
|
||||||
# Check for Node.js version
|
rm -rf node_modules/@prisma/internals/node_modules/@prisma/engines 2>/dev/null || true
|
||||||
NODE_VERSION=$(node -v)
|
rm -rf node_modules/@prisma/internals/node_modules/@prisma/engines-version 2>/dev/null || true
|
||||||
echo "Node.js version: $NODE_VERSION" | tee -a "$LOG_FILE"
|
rm -rf node_modules/@prisma/client/node_modules/@prisma/engines-version 2>/dev/null || true
|
||||||
|
|
||||||
# Clean up node_modules
|
|
||||||
echo "Cleaning up node_modules..." | tee -a "$LOG_FILE"
|
|
||||||
|
|
||||||
# Remove specific problematic packages
|
|
||||||
echo "Removing problematic packages..." | tee -a "$LOG_FILE"
|
|
||||||
rm -rf node_modules/abbrev
|
|
||||||
rm -rf node_modules/bcrypt
|
|
||||||
rm -rf node_modules/node-pre-gyp
|
|
||||||
rm -rf node_modules/.bin/node-pre-gyp
|
|
||||||
|
|
||||||
# Clean npm cache
|
# Clean npm cache
|
||||||
echo "Cleaning npm cache..." | tee -a "$LOG_FILE"
|
echo "[$(date)] Cleaning npm cache..." | tee -a $LOG_FILE
|
||||||
npm cache clean --force
|
npm cache clean --force
|
||||||
|
|
||||||
# Install specific problematic packages individually
|
# Fix nested node_modules issues
|
||||||
echo "Installing problematic packages individually..." | tee -a "$LOG_FILE"
|
echo "[$(date)] Removing nested node_modules..." | tee -a $LOG_FILE
|
||||||
|
find node_modules -type d -name "node_modules" -not -path "node_modules" -exec rm -rf {} + 2>/dev/null || true
|
||||||
|
|
||||||
echo "Installing abbrev..." | tee -a "$LOG_FILE"
|
# Install critical packages individually
|
||||||
npm install abbrev@latest --no-save --no-audit --no-fund || echo "Failed to install abbrev" | tee -a "$LOG_FILE"
|
echo "[$(date)] Installing critical packages individually..." | tee -a $LOG_FILE
|
||||||
|
npm install abbrev@latest --no-save --no-audit --no-fund | tee -a $LOG_FILE
|
||||||
|
npm install bcrypt@latest --build-from-source --no-save --no-audit --no-fund | tee -a $LOG_FILE
|
||||||
|
|
||||||
echo "Installing bcrypt..." | tee -a "$LOG_FILE"
|
# Install specific Prisma versions
|
||||||
npm install bcrypt@latest --build-from-source --no-save --no-audit --no-fund || echo "Failed to install bcrypt" | tee -a "$LOG_FILE"
|
echo "[$(date)] Installing specific Prisma versions..." | tee -a $LOG_FILE
|
||||||
|
npm uninstall prisma @prisma/client --no-save | tee -a $LOG_FILE
|
||||||
|
npm install prisma@5.12.0 @prisma/client@5.12.0 --save-exact --no-audit --no-fund | tee -a $LOG_FILE
|
||||||
|
|
||||||
# Try reinstalling all dependencies
|
# Reinstall all dependencies with safer options
|
||||||
echo "Reinstalling all dependencies..." | tee -a "$LOG_FILE"
|
echo "[$(date)] Reinstalling all dependencies..." | tee -a $LOG_FILE
|
||||||
npm install --production --no-optional --legacy-peer-deps ||
|
npm install --production --no-optional --legacy-peer-deps | tee -a $LOG_FILE
|
||||||
npm install --production --no-optional --force ||
|
|
||||||
npm install --production --no-optional --no-package-lock ||
|
|
||||||
echo "WARNING: All npm install attempts failed" | tee -a "$LOG_FILE"
|
|
||||||
|
|
||||||
# Generate Prisma client
|
# Generate Prisma client
|
||||||
echo "Generating Prisma client..." | tee -a "$LOG_FILE"
|
echo "[$(date)] Generating Prisma client..." | tee -a $LOG_FILE
|
||||||
npx prisma generate || echo "Failed to generate Prisma client" | tee -a "$LOG_FILE"
|
npx prisma generate | tee -a $LOG_FILE
|
||||||
|
|
||||||
# Build Next.js application
|
# Rebuild Next.js
|
||||||
echo "Building Next.js application..." | tee -a "$LOG_FILE"
|
echo "[$(date)] Building Next.js application..." | tee -a $LOG_FILE
|
||||||
npx next build || echo "Failed to build Next.js application" | tee -a "$LOG_FILE"
|
npx next build | tee -a $LOG_FILE
|
||||||
|
|
||||||
echo "====================================================="
|
echo "[$(date)] Fix script completed. Check for any errors above." | tee -a $LOG_FILE
|
||||||
echo "Fix script completed at $(date)" | tee -a "$LOG_FILE"
|
echo "[$(date)] You may need to restart the application now: npm start" | tee -a $LOG_FILE
|
||||||
echo "Check $LOG_FILE for detailed output"
|
|
||||||
echo "====================================================="
|
|
||||||
|
|
||||||
echo "To restart the application, run:"
|
# Print instructions for running the script in the background
|
||||||
echo "1. Find the process ID: ps aux | grep 'npm start'"
|
cat << "EOF"
|
||||||
echo "2. Kill the process: kill <PID>"
|
|
||||||
echo "3. Restart: npm start"
|
To run this script in the background (detached from terminal):
|
||||||
echo "Or use: pkill -f 'npm start' && npm start"
|
nohup /app/_deploy/fix-npm-issues.sh > /app/logs/npm-fix.log 2>&1 &
|
||||||
echo "====================================================="
|
|
||||||
|
To monitor progress:
|
||||||
|
tail -f /app/logs/npm-fix.log
|
||||||
|
|
||||||
|
To restart the application after fixing:
|
||||||
|
pkill -f "npm start" || true
|
||||||
|
nohup npm start > /app/logs/app.log 2>&1 &
|
||||||
|
|
||||||
|
EOF
|
Reference in New Issue
Block a user