New deployment script added
This commit is contained in:
30
scripts/deploy.sh
Normal file
30
scripts/deploy.sh
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
APP_NAME="kotisivu"
|
||||||
|
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
PORT="${1:-${PORT:-3000}}"
|
||||||
|
|
||||||
|
echo "Deploying $APP_NAME from $APP_DIR on port $PORT..."
|
||||||
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
|
||||||
|
echo "Pulling latest changes..."
|
||||||
|
sudo -E git pull
|
||||||
|
|
||||||
|
echo "Installing dependencies..."
|
||||||
|
sudo bun install
|
||||||
|
|
||||||
|
echo "Building application..."
|
||||||
|
sudo bun run build
|
||||||
|
|
||||||
|
echo "Starting/reloading with pm2..."
|
||||||
|
if sudo pm2 describe "$APP_NAME" > /dev/null 2>&1; then
|
||||||
|
sudo pm2 reload "$APP_NAME" --update-env
|
||||||
|
else
|
||||||
|
sudo pm2 start bun --name "$APP_NAME" --env PORT="$PORT" -- run start
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo pm2 save
|
||||||
|
|
||||||
|
echo "Deployment complete."
|
||||||
Reference in New Issue
Block a user