-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_server.sh
More file actions
34 lines (27 loc) · 759 Bytes
/
deploy_server.sh
File metadata and controls
34 lines (27 loc) · 759 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
#!/usr/bin/env bash
set -euo pipefail
if [ $# -lt 1 ]; then
echo "Usage: $0 <repo-url> [branch]"
echo "Example: $0 https://github.com/username/cpp-project.git main"
exit 1
fi
REPO_URL="$1"
BRANCH="${2:-main}"
APP_DIR="$HOME/cpp-project"
if [ -d "$APP_DIR/.git" ]; then
echo "Project already exists. Pulling latest code..."
git -C "$APP_DIR" fetch origin
git -C "$APP_DIR" checkout "$BRANCH"
git -C "$APP_DIR" pull origin "$BRANCH"
else
echo "Cloning project..."
git clone --branch "$BRANCH" "$REPO_URL" "$APP_DIR"
fi
cd "$APP_DIR"
echo "Starting/Updating containers..."
docker compose up -d --build
echo "Deployment complete."
echo "Container status:"
docker compose ps
echo "Recent logs:"
docker compose logs --tail=50 search-server