Skip to content

Commit 6b482fc

Browse files
committed
cd: Blue/Green 배포 구조 개선 (active-slot.txt로 Active 관리)
1 parent 137534d commit 6b482fc

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

.github/workflows/cd.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ jobs:
3737
set -e
3838
cd ~/deploy
3939
40-
echo "🔍 Detecting active container..."
40+
echo "🔍 Reading active slot..."
41+
ACTIVE=$(cat active-slot.txt)
4142
42-
if docker ps --filter "name=concert-spring-blue" --format "{{.Status}}" | grep -q healthy; then
43-
ACTIVE=blue
43+
if [ "$ACTIVE" = "blue" ]; then
4444
TARGET=green
4545
PORT=8082
4646
else
47-
ACTIVE=green
4847
TARGET=blue
4948
PORT=8081
5049
fi
@@ -68,12 +67,20 @@ jobs:
6867
echo "⏳ still waiting..."
6968
sleep 5
7069
done
71-
72-
if [ "$HEALTHY" = "true" ]; then
73-
echo "✅ spring-$TARGET is healthy"
74-
exit 0
70+
71+
if [ "$HEALTHY" != "true" ]; then
72+
echo "❌ Health check failed for spring-$TARGET - rolling back"
73+
docker compose -f docker-compose-prod.yml stop spring-$TARGET
74+
exit 1
7575
fi
76-
77-
echo "❌ Health check failed for spring-$TARGET - rolling back"
78-
docker compose -f docker-compose-prod.yml stop spring-$TARGET
79-
exit 1
76+
77+
echo "✅ spring-$TARGET is healthy"
78+
79+
echo "🔀 (MANUAL) Switch NPM forward port to $PORT"
80+
echo "✍️ Update active slot"
81+
echo "$TARGET" > active-slot.txt
82+
83+
echo "🛑 Stop old container: spring-$ACTIVE"
84+
docker compose -f docker-compose-prod.yml stop spring-$ACTIVE
85+
86+
echo "🎉 Blue/Green deployment completed"

0 commit comments

Comments
 (0)