Skip to content

Instantly share code, notes, and snippets.

@testfailed
Forked from Kamleshpaul/nextjs-pm2-deploy.sh
Last active June 14, 2022 07:16
Show Gist options
  • Save testfailed/8a1950a51005c1b2406daada1e4302a1 to your computer and use it in GitHub Desktop.
Save testfailed/8a1950a51005c1b2406daada1e4302a1 to your computer and use it in GitHub Desktop.

Revisions

  1. testfailed revised this gist Feb 26, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nextjs-pm2-deploy
    Original file line number Diff line number Diff line change
    @@ -26,3 +26,5 @@ function deploy() {
    echo "Deploy done!"
    # make sure `next.config.js` it set `distDir: process.env.BUILD_DIR`
    }

    deploy "$@"
  2. testfailed revised this gist Feb 26, 2022. 2 changed files with 28 additions and 25 deletions.
    28 changes: 28 additions & 0 deletions nextjs-pm2-deploy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/usr/bin/env bash
    # set -euo pipefail
    # IFS=$'\n\t'

    function deploy() {
    # zero downtime deployment nextjs without vercel

    echo "Deploy starting..."

    git pull

    yarn install || exit

    BUILD_DIR=temp yarn build || exit

    if [ ! -d "temp" ]; then
    echo '\033[31m directory "temp" does not exists!\033[0m'
    exit 1;
    fi

    rm -rf .next
    mv temp .next

    pm2 reload ecosystem.config.production.js --update-env

    echo "Deploy done!"
    # make sure `next.config.js` it set `distDir: process.env.BUILD_DIR`
    }
    25 changes: 0 additions & 25 deletions nextjs-pm2-deploy.sh
    Original file line number Diff line number Diff line change
    @@ -1,25 +0,0 @@
    #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`
  3. @Kamleshpaul Kamleshpaul revised this gist Jan 24, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nextjs-pm2-deploy.sh
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ rm -rf .next

    mv temp .next

    pm2 reload app
    pm2 reload app --update-env

    echo "Deploy done."

  4. @Kamleshpaul Kamleshpaul revised this gist Jan 23, 2022. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions nextjs-pm2-deploy.sh
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,15 @@ echo "Deploy starting..."

    git pull

    npm install
    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

    BUILD_DIR=temp npm run build

    rm -rf .next

  5. @Kamleshpaul Kamleshpaul revised this gist Dec 28, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nextjs-pm2-deploy.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #zero downtime deployment on pm2
    #zero downtime deployment nextjs without vercel

    echo "Deploy starting..."

  6. @Kamleshpaul Kamleshpaul revised this gist Dec 28, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nextjs-pm2-deploy.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    #zero downtime deployment on pm2

    echo "Deploy starting..."

    git pull
  7. @Kamleshpaul Kamleshpaul created this gist Dec 28, 2021.
    17 changes: 17 additions & 0 deletions nextjs-pm2-deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    echo "Deploy starting..."

    git pull

    npm install

    BUILD_DIR=temp npm run build

    rm -rf .next

    mv temp .next

    pm2 reload app

    echo "Deploy done."

    #make sure `next.config.js` it set `distDir: process.env.BUILD_DIR`