Next.js Discord

Discord Forum

Help, "Almost zero downtime but not quite Blue/Green Deployment" broken when running next build

Unanswered
Common Murre posted this in #help-forum
Open in Discord
Common MurreOP
I'm trying to do a simple GitHub action CI. This is my script

npm i BUILD_DIR=temp-build npm run build --if-present if [ ! -d "temp-build" ]; then echo 'Temp Directory not exists!' mv temp-build .next if pm2 describe "${{ github.repository }}" > /dev/null then pm2 reload "${{ github.repository }}" --update-env else exit 1; fi rm -rf .next HOST='1.2.3.4' PORT=3000 pm2 start npm --name "${{ github.repository }}" -- start --watch fi pm2 describe "${{ github.repository }}" pm2 save

I also add this on my next.config.js
distDir: process.env.BUILD_DIR || '.next',

So the point is to have temporary build dir before then quickly replace the ".next" folder and reload PM2. But seems like whenever env of the build dir is changed and next build is executed, the deployment switched to the temp build dir immediately. How can I fix this?

0 Replies