-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
60 lines (46 loc) · 1.37 KB
/
Copy pathdeploy.sh
File metadata and controls
60 lines (46 loc) · 1.37 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
#!/usr/bin/env bash
set -Eeuo pipefail
APP_NAME="payment-gateway"
HEALTH_URL="http://localhost:8080/actuator/health/readiness"
MAX_ATTEMPTS=20
WAIT_SECONDS=10
echo "======================================"
echo "Deploying Ficmart Payment Gateway"
echo "======================================"
cd "$(dirname "$0")"
if [ ! -f ".env" ]; then
echo "Deployment failed: .env file was not found."
exit 1
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Deployment failed: Docker is not installed."
exit 1
fi
if ! docker compose version >/dev/null 2>&1; then
echo "Deployment failed: Docker Compose is not installed."
exit 1
fi
echo
echo "Pulling the latest code from GitHub..."
git pull --ff-only
echo
echo "Building and starting containers..."
docker compose up --build -d
echo
echo "Waiting for the application to become healthy..."
for attempt in $(seq 1 "$MAX_ATTEMPTS"); do
if curl --fail --silent "$HEALTH_URL" >/dev/null; then
echo
echo "Deployment completed successfully."
echo "Health endpoint: $HEALTH_URL"
docker compose ps
exit 0
fi
echo "Health check attempt $attempt/$MAX_ATTEMPTS failed. Retrying in ${WAIT_SECONDS}s..."
sleep "$WAIT_SECONDS"
done
echo
echo "Deployment failed: the application did not become healthy."
echo "Recent application logs:"
docker compose logs --tail=100 "$APP_NAME"
exit 1