-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·65 lines (51 loc) · 1.29 KB
/
deploy.sh
File metadata and controls
executable file
·65 lines (51 loc) · 1.29 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# Deploy script for useragent-one:
#
# - pull updates from github
# - rebuild docker containers with new updates
# - reload nginx
# - run with "--no-pull" to skip pulling from rpeo
#
# Usage:
#
# sudo chmod +x deploy.sh
# - run as sudo!
#
# Examples:
#
# sudo ./deploy.sh
# sudo ./deploy.sh --no-pull
set -e # Exit on error
if [ ! -f .env ]; then
echo "⚠️ .env file not found! Deploy may fail if required vars are missing."
read -p "Do you want to continue anyway? [y/N]: " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "🛑 Exiting deploy."
exit 1
fi
fi
SKIP_PULL=false
if [[ "$1" == "--no-pull" ]]; then
SKIP_PULL=true
fi
sudo -v
echo "Updating app on server..."
if [ "$SKIP_PULL" = false ]; then
echo -e "\n[1/6] Pulling latest changes..."
git pull origin master
else
echo -e "\n[1/6] Skipping git pull (per --no-pull)"
fi
echo -e "\n[2/6] Shutting down containers..."
docker compose down
echo -e "\n[3/6] Pruning old Docker resources from this project..."
docker compose rm -f
docker image prune -f
echo -e "\n[4/6] Rebuilding without cache..."
docker compose build --no-cache
echo -e "\n[5/6] Starting containers..."
docker compose up -d
# echo -e "\n[6/6] Reloading Nginx (sudo)..."
# systemctl reload nginx
echo -e "\n✅ App updated successfully."