Skip to content

Commit

Permalink
add temp build for zero downtime
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Aug 14, 2024
1 parent 15a0c94 commit 01d5f52
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 83 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ jobs:
# execute commands
script: |
cd ~/matheditor
echo "Pulling latest changes..."
git fetch
git reset --hard origin/master
echo "Installing dependencies..."
npm ci
npx prisma migrate deploy
npm run build
pm2 reload "matheditor"
echo "Building to temp directory..."
BUILD_DIR=temp npm run build || exit
if [ ! -d "temp" ]; then
echo '\033[31m temp Directory not exists!\033[0m'
exit 1;
fi
echo "Switching live directory..."
rm -rf .next
mv temp .next
pm2 reload matheditor --update-env
echo "Deploy done."
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# production
/build
/dist
/temp

# misc
.DS_Store
Expand Down
81 changes: 0 additions & 81 deletions deploy.sh

This file was deleted.

1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const withPWA = require("./next-pwa")({
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: false,
distDir: process.env.BUILD_DIR || '.next',
/** @param { import('webpack').Configuration } config */
webpack: (config, { isServer }) => {
if (isServer) {
Expand Down

0 comments on commit 01d5f52

Please sign in to comment.