-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
40 lines (30 loc) · 844 Bytes
/
deploy.sh
File metadata and controls
40 lines (30 loc) · 844 Bytes
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
#!/bin/sh
SERVICE_NAME="webapp"
GIT_BRANCH="stable"
if [ "$(id -u)" -eq 0 ]; then
echo "This script must not be run as root."
exit 1
fi
# Find service path
if [ ! -f "$(pwd)/.service_paths" ]; then
echo "Did you initialize the service using server-init.sh?: .service_paths not found."
exit 1
fi
SERVICE_PATH=$(cat $(pwd)/.service_paths | grep $SERVICE_NAME | cut -d' ' -f2)
if [ -z "$SERVICE_PATH" ] || [ ! -d "$SERVICE_PATH" ]; then
echo "Service path invalid or missing."
exit 1
fi
cd $SERVICE_PATH
# Checkout the latest commit
git fetch origin -v
git checkout origin/$GIT_BRANCH
# Use Docker Compose
echo "Building and starting Docker containers..."
docker compose up -d --build
if [ "$?" -ne 0 ]; then
echo "Docker compose failed to start the service."
exit 1
fi
echo "Deployment successful."
docker image prune -f