Skip to content

Instantly share code, notes, and snippets.

@Kamleshpaul
Last active May 2, 2024 02:55
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Kamleshpaul/d22887c48e0c0d231734da24e8a80660 to your computer and use it in GitHub Desktop.
Save Kamleshpaul/d22887c48e0c0d231734da24e8a80660 to your computer and use it in GitHub Desktop.
#zero downtime deployment nextjs without vercel
echo "Deploy starting..."
git pull
npm install || exit
BUILD_DIR=temp npm run build || exit
if [ ! -d "temp" ]; then
echo '\033[31m temp Directory not exists!\033[0m'
exit 1;
fi
rm -rf .next
mv temp .next
pm2 reload app --update-env
echo "Deploy done."
#make sure `next.config.js` it set `distDir: process.env.BUILD_DIR`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment