-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy_docker.sh
More file actions
executable file
·35 lines (24 loc) · 1.01 KB
/
deploy_docker.sh
File metadata and controls
executable file
·35 lines (24 loc) · 1.01 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
#!/bin/bash
# Check if the token is provided
if [ -z "$1" ]; then
echo "Usage: $0 <DRD_CLOUD_API_TOKEN>"
exit 1
fi
DRD_CLOUD_API_TOKEN=$1
echo "🔽 Bringing down Docker Compose stack..."
docker-compose -f agent.docker-compose.yaml down
echo "📦 Stashing local changes (if any)..."
git stash
echo "⬇️ Pulling latest changes from origin/main..."
git pull origin main
echo "📤 Reapplying stashed changes (if any)..."
git stash pop
echo "🗑️ Removing old Docker container (if exists)..."
docker rm -f drd_agent 2>/dev/null || echo "No existing container to remove."
echo "🗑️ Removing old Docker image (if exists)..."
docker rmi drd_agent 2>/dev/null || echo "No existing image to remove."
echo "📝 Capturing current commit hash..."
COMMIT_HASH=$(git rev-parse HEAD)
echo "🚀 Starting Docker Compose with new deployment... with commit hash: $COMMIT_HASH"
DRD_CLOUD_API_TOKEN="$DRD_CLOUD_API_TOKEN" COMMIT_HASH="$COMMIT_HASH" docker-compose -f agent.docker-compose.yaml up -d
echo "✅ Deployment complete."