Merge branch 'main' of https://git.gnxsoft.com/gnx/GNX-WEB
This commit is contained in:
@@ -211,10 +211,48 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
<<<<<<< HEAD
|
||||
# Set PORT environment variable and start with PM2
|
||||
PORT=$FRONTEND_PORT NODE_ENV=production pm2 start npm \
|
||||
--name "gnxsoft-frontend" \
|
||||
-- start
|
||||
=======
|
||||
# Check if Next.js is using standalone output mode
|
||||
if grep -q '"output":\s*"standalone"' next.config.js 2>/dev/null || grep -q "output:.*'standalone'" next.config.js 2>/dev/null; then
|
||||
echo -e "${BLUE}Detected standalone mode. Starting with standalone server...${NC}"
|
||||
|
||||
# Check if standalone server exists
|
||||
if [ ! -f ".next/standalone/server.js" ]; then
|
||||
echo -e "${YELLOW}Standalone server not found. Rebuilding...${NC}"
|
||||
NODE_ENV=production PORT=$FRONTEND_PORT npm run build
|
||||
fi
|
||||
|
||||
# Ensure public folder is copied to standalone directory
|
||||
if [ ! -d ".next/standalone/public" ]; then
|
||||
echo -e "${BLUE}Copying public folder to standalone directory...${NC}"
|
||||
cp -r public .next/standalone/
|
||||
fi
|
||||
|
||||
# Ensure static folder symlink exists for image optimization
|
||||
if [ ! -L ".next/standalone/.next/static" ] && [ ! -d ".next/standalone/.next/static" ]; then
|
||||
echo -e "${BLUE}Creating symlink for static files...${NC}"
|
||||
mkdir -p .next/standalone/.next
|
||||
ln -s ../../static .next/standalone/.next/static
|
||||
fi
|
||||
|
||||
# Start standalone server with PM2
|
||||
PORT=$FRONTEND_PORT NODE_ENV=production pm2 start node \
|
||||
--name "gnxsoft-frontend" \
|
||||
--cwd "$FRONTEND_DIR" \
|
||||
-- \
|
||||
".next/standalone/server.js"
|
||||
else
|
||||
# Standard Next.js start
|
||||
PORT=$FRONTEND_PORT NODE_ENV=production pm2 start npm \
|
||||
--name "gnxsoft-frontend" \
|
||||
-- start
|
||||
fi
|
||||
>>>>>>> d7d7a2757a183aa1abd9dbabff804c45298df4e5
|
||||
|
||||
# Save PM2 configuration
|
||||
pm2 save
|
||||
|
||||
Reference in New Issue
Block a user