forked from leerob/next-self-host
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
31 lines (25 loc) · 852 Bytes
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Script Vars
REPO_URL="https://github.com/leerob/next-self-host.git"
APP_DIR=~/myapp
# Pull the latest changes from the Git repository
if [ -d "$APP_DIR" ]; then
echo "Pulling latest changes from the repository..."
cd $APP_DIR
git pull origin main
else
echo "Cloning repository from $REPO_URL..."
git clone $REPO_URL $APP_DIR
cd $APP_DIR
fi
# Build and restart the Docker containers from the app directory (~/myapp)
echo "Rebuilding and restarting Docker containers..."
sudo docker-compose down
sudo docker-compose up --build -d
# Check if Docker Compose started correctly
if ! sudo docker-compose ps | grep "Up"; then
echo "Docker containers failed to start. Check logs with 'docker-compose logs'."
exit 1
fi
# Output final message
echo "Update complete. Your Next.js app has been deployed with the latest changes."