fix: revert Nginx and Blue/Green deployment to restore stable Apache connection
Some checks are pending
Deploy to OCIWP / deploy (push) Waiting to run
Some checks are pending
Deploy to OCIWP / deploy (push) Waiting to run
This commit is contained in:
@@ -17,52 +17,28 @@ jobs:
|
||||
|
||||
- name: Sync Code to Host Volume
|
||||
run: |
|
||||
echo "Cleaning up old src directories to prevent stale source files..."
|
||||
rm -rf /app/*/src
|
||||
echo "Copying latest code to /app (Host Volume)..."
|
||||
cp -a . /app/
|
||||
|
||||
- name: Deploy Task on Host
|
||||
run: |
|
||||
echo "Starting Blue-Green CI/CD Deploy pipeline..."
|
||||
echo "Starting Standard CI/CD Deploy pipeline..."
|
||||
|
||||
# 1. (?<3F>거?? ?<3F>스??볼륨?<3F>서??불필?<3F>한 gradle 빌드 ?<3F>외 - Dockerfile ?<3F>에???<3F><>? ?<3F>행?<3F><>?<3F>?OOM 방<>?)
|
||||
# 1. gradle 공식 이미지로 바로 컴파일 빌드!
|
||||
docker run --rm \
|
||||
-v /home/ubuntu/app/ax_hub_mcp_tool:/app \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /home/ubuntu/.gradle:/home/gradle/.gradle \
|
||||
-w /app \
|
||||
gradle:8-jdk21 \
|
||||
./gradlew bootJar -x test
|
||||
|
||||
cd /app
|
||||
# 2. 빌드 결과 plain jar 아카이브 정리
|
||||
find /app -name "*-plain.jar" -delete
|
||||
|
||||
# 3. 블루/그린 ?<3F><>??<3F>별
|
||||
IS_BLUE_RUNNING=$(docker ps --filter "name=ax_hub_mcp_tool-gateway-blue-1" --filter "status=running" -q)
|
||||
|
||||
if [ ! -z "$IS_BLUE_RUNNING" ]; then
|
||||
echo "Current active color is BLUE. Deploying to GREEN..."
|
||||
TARGET="green"
|
||||
OLD_TARGET="blue"
|
||||
else
|
||||
echo "Current active color is GREEN (or none). Deploying to BLUE..."
|
||||
TARGET="blue"
|
||||
OLD_TARGET="green"
|
||||
fi
|
||||
|
||||
# 3.5. 공통 ?<3F>프??(DB, Redis ?? 먼<>? ?<3F>우<EFBFBD>?(Nginx ?<3F>외)
|
||||
ACTIVE_PROFILE=dev docker compose up -d redis mci-mock dozzle
|
||||
|
||||
# 4. ?<3F>규 버전(TARGET) 컨테?<3F>너 기동
|
||||
echo "Building and starting $TARGET containers sequentially to prevent OOM..."
|
||||
ACTIVE_PROFILE=dev docker compose build gateway-$TARGET
|
||||
ACTIVE_PROFILE=dev docker compose build tool-sms-$TARGET
|
||||
ACTIVE_PROFILE=dev docker compose build tool-other-$TARGET
|
||||
|
||||
ACTIVE_PROFILE=dev docker compose up -d gateway-$TARGET
|
||||
sleep 5
|
||||
ACTIVE_PROFILE=dev docker compose up -d tool-sms-$TARGET
|
||||
sleep 5
|
||||
sleep 5
|
||||
ACTIVE_PROFILE=dev docker compose up -d tool-other-$TARGET
|
||||
sleep 5
|
||||
|
||||
# 4.5. 제거할 컨테이너 (포트 충돌 방지, Nginx 제외)
|
||||
echo "Finding and killing legacy containers holding our ports..."
|
||||
for port in 6379 8089 8281 8282 8283 8284 8285 8288; do
|
||||
# 3. 좀비 컨테이너 청소 (현재 우리가 쓸 포트를 점유 중인 옛날 컨테이너들만 정확히 색출해서 사살)
|
||||
echo "Finding and killing zombie containers holding our ports..."
|
||||
for port in 6379 8080 8089 8281 8282 8283 8284 8285 8288; do
|
||||
cid=$(docker ps -q --filter "publish=$port")
|
||||
if [ ! -z "$cid" ]; then
|
||||
echo "Force killing container $cid using port $port"
|
||||
@@ -70,58 +46,13 @@ jobs:
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# 4.6. Nginx 초기 ?정 ?기동
|
||||
mkdir -p ./nginx/conf.d
|
||||
echo "Initializing Nginx config to $TARGET..."
|
||||
cp ./nginx/${TARGET}.conf ./nginx/conf.d/default.conf
|
||||
ACTIVE_PROFILE=dev docker compose up -d nginx
|
||||
|
||||
# 5. Health Check (??버전???상?으??는지 ?인)
|
||||
echo "Fetching gateway logs..."
|
||||
docker logs --tail 100 ax_hub_mcp_tool-gateway-$TARGET-1
|
||||
echo "Waiting 30 seconds for services to fully start..."
|
||||
sleep 30
|
||||
|
||||
# ?규 컨테?너가 죽? ?고 ?아?는지 ?인
|
||||
IS_TARGET_ALIVE=$(docker ps --filter "name=ax_hub_mcp_tool-gateway-${TARGET}-1" --filter "status=running" -q)
|
||||
|
||||
if [ -z "$IS_TARGET_ALIVE" ]; then
|
||||
echo "Health Check Failed! $TARGET container crashed. Rollback."
|
||||
echo "Rolling back Nginx config to $OLD_TARGET..."
|
||||
cp ./nginx/${OLD_TARGET}.conf ./nginx/conf.d/default.conf
|
||||
echo "Restarting Nginx to apply rollback..."
|
||||
docker compose restart nginx || true
|
||||
echo "Stopping failed $TARGET containers..."
|
||||
docker compose stop gateway-$TARGET tool-sms-$TARGET tool-other-$TARGET
|
||||
exit 1 # ?<3F>이?<3F>라???<3F>패 처리 (구버?<3F><>? 그<>?<3F>??<3F><>???
|
||||
fi
|
||||
|
||||
# 6. ?<3F>래???<3F>환 (Nginx ?<3F>정 ?<3F>위<EFBFBD>?
|
||||
echo "Health Check Passed! Switching traffic to $TARGET..."
|
||||
mkdir -p ./nginx/conf.d
|
||||
cp ./nginx/${TARGET}.conf ./nginx/conf.d/default.conf
|
||||
|
||||
if ! docker compose exec -T nginx nginx -s reload; then
|
||||
echo "Nginx reload failed! Rolling back Nginx configuration..."
|
||||
cp ./nginx/${OLD_TARGET}.conf ./nginx/conf.d/default.conf
|
||||
docker compose exec -T nginx nginx -s reload || true
|
||||
echo "Stopping failed $TARGET containers..."
|
||||
docker compose stop gateway-$TARGET tool-sms-$TARGET tool-other-$TARGET
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 7. 구버??종료
|
||||
echo "Traffic switched successfully. Stopping old $OLD_TARGET containers..."
|
||||
docker compose stop gateway-$OLD_TARGET tool-sms-$OLD_TARGET tool-other-$OLD_TARGET
|
||||
|
||||
# 가비<EAB080>? <20>?<3F><>
|
||||
# 4. 마운트된 /app 디렉토리로 이동하여 호스트의 도커 컴포즈 제어!
|
||||
cd /app
|
||||
docker system prune -f
|
||||
ACTIVE_PROFILE=dev docker compose down
|
||||
ACTIVE_PROFILE=dev docker compose up -d --build gateway redis mci-mock dozzle tool-sms tool-other
|
||||
|
||||
# 5. 배포 후 대롱대롱 매달려 있는 가비지 이미지 자동 소거 청소!
|
||||
docker image prune -f
|
||||
|
||||
echo "Blue-Green CI/CD Deploy Success! Currently running: $TARGET"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "CI/CD Deploy Success!"
|
||||
|
||||
@@ -11,6 +11,27 @@ services:
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
gateway:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-gateway/Dockerfile
|
||||
ports:
|
||||
- "8281:8081"
|
||||
volumes:
|
||||
- ./:/src
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_HOST=redis
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_SOURCE_DIR=/src
|
||||
- JAVA_TOOL_OPTIONS=-Xms64m -Xmx384m
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
|
||||
mci-mock:
|
||||
image: wiremock/wiremock:latest
|
||||
ports:
|
||||
@@ -18,6 +39,53 @@ services:
|
||||
volumes:
|
||||
- ./mci-mock:/home/wiremock
|
||||
|
||||
tool-sms:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-tool-sms/Dockerfile
|
||||
ports:
|
||||
- "8282:8082"
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_GATEWAY_URL=http://gateway:8081
|
||||
- AXHUB_SOURCE_DIR=/src
|
||||
- AXHUB_TOOL_URL=http://tool-sms:8082
|
||||
- GLOW_COMMUNICATION_MCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_MCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EXTMCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EXTMCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EAI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EAI_PORT=8080
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
|
||||
tool-other:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-tool-other/Dockerfile
|
||||
ports:
|
||||
- "8284:8084"
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_GATEWAY_URL=http://gateway:8081
|
||||
- AXHUB_TOOL_URL=http://tool-other:8084
|
||||
- GLOW_COMMUNICATION_MCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_MCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EXTMCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EXTMCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EAI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EAI_PORT=8080
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
|
||||
dozzle:
|
||||
image: amir20/dozzle:latest
|
||||
ports:
|
||||
@@ -42,157 +110,3 @@ services:
|
||||
- ./bin/docker:/usr/bin/docker
|
||||
- /usr/libexec/docker/cli-plugins/docker-compose:/usr/libexec/docker/cli-plugins/docker-compose
|
||||
restart: always
|
||||
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- "8080:8281"
|
||||
- "8282:8282"
|
||||
- "8283:8283"
|
||||
- "8284:8284"
|
||||
- "8285:8285"
|
||||
volumes:
|
||||
- ./nginx/conf.d:/etc/nginx/conf.d
|
||||
- ./nginx/ssl:/etc/nginx/ssl
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
restart: always
|
||||
|
||||
# ==========================================
|
||||
# BLUE SERVICES
|
||||
# ==========================================
|
||||
gateway-blue:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-gateway/Dockerfile
|
||||
volumes:
|
||||
- ./:/src
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_HOST=redis
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_SOURCE_DIR=/src
|
||||
- JAVA_TOOL_OPTIONS=-Xms64m -Xmx384m
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
- MCP_GATEWAY_FALLBACK_DEFAULT_URL=http://tool-other-blue:8084
|
||||
- MCP_GATEWAY_FALLBACK_ROUTES_SMS=http://tool-sms-blue:8082
|
||||
- MCP_GATEWAY_FALLBACK_ROUTES_HR=http://tool-other-blue:8084
|
||||
|
||||
tool-sms-blue:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-tool-sms/Dockerfile
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_GATEWAY_URL=http://gateway-blue:8081
|
||||
- AXHUB_SOURCE_DIR=/src
|
||||
- AXHUB_TOOL_URL=http://tool-sms-blue:8082
|
||||
- GLOW_COMMUNICATION_MCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_MCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EXTMCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EXTMCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EAI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EAI_PORT=8080
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
tool-other-blue:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-tool-other/Dockerfile
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_GATEWAY_URL=http://gateway-blue:8081
|
||||
- AXHUB_TOOL_URL=http://tool-other-blue:8084
|
||||
- GLOW_COMMUNICATION_MCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_MCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EXTMCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EXTMCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EAI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EAI_PORT=8080
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
# ==========================================
|
||||
# GREEN SERVICES
|
||||
# ==========================================
|
||||
gateway-green:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-gateway/Dockerfile
|
||||
volumes:
|
||||
- ./:/src
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_HOST=redis
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_SOURCE_DIR=/src
|
||||
- JAVA_TOOL_OPTIONS=-Xms64m -Xmx384m
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
- MCP_GATEWAY_FALLBACK_DEFAULT_URL=http://tool-other-green:8084
|
||||
- MCP_GATEWAY_FALLBACK_ROUTES_SMS=http://tool-sms-green:8082
|
||||
- MCP_GATEWAY_FALLBACK_ROUTES_HR=http://tool-other-green:8084
|
||||
|
||||
tool-sms-green:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-tool-sms/Dockerfile
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_GATEWAY_URL=http://gateway-green:8081
|
||||
- AXHUB_SOURCE_DIR=/src
|
||||
- AXHUB_TOOL_URL=http://tool-sms-green:8082
|
||||
- GLOW_COMMUNICATION_MCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_MCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EXTMCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EXTMCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EAI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EAI_PORT=8080
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
tool-other-green:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dap-tool-other/Dockerfile
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
- TZ=Asia/Seoul
|
||||
- SPRING_REDIS_HOST=redis
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_DATA_REDIS_PORT=6379
|
||||
- AXHUB_GATEWAY_URL=http://gateway-green:8081
|
||||
- AXHUB_TOOL_URL=http://tool-other-green:8084
|
||||
- GLOW_COMMUNICATION_MCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_MCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EXTMCI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EXTMCI_PORT=8080
|
||||
- GLOW_COMMUNICATION_EAI_HOMT=http://mci-mock
|
||||
- GLOW_COMMUNICATION_EAI_PORT=8080
|
||||
- SPRING_PROFILES_ACTIVE=${ACTIVE_PROFILE:-local}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
upstream gateway {
|
||||
server gateway-blue:8081;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8281;
|
||||
|
||||
location / {
|
||||
proxy_pass http://gateway;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
upstream gateway {
|
||||
server gateway-blue:8081;
|
||||
}
|
||||
|
||||
upstream tool-sms {
|
||||
server tool-sms-blue:8082;
|
||||
}
|
||||
|
||||
upstream tool-other {
|
||||
server tool-other-blue:8084;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8281;
|
||||
location / {
|
||||
proxy_pass http://gateway;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8282;
|
||||
location / {
|
||||
proxy_pass http://tool-sms;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8284;
|
||||
location / {
|
||||
proxy_pass http://tool-other;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
upstream gateway {
|
||||
server gateway-green:8081;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8281;
|
||||
|
||||
location / {
|
||||
proxy_pass http://gateway;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user