배포를 main push 자동 + blue-green 무중단 전환으로 개편 - #27
Conversation
- 트리거에 push(main)를 더해 머지가 곧 배포가 되게 한다. renderer #15 가 머지 후 수동 트리거 누락으로 이틀 미배포된 사고가 계기 - "교체식 단일 컨테이너 + 수초 다운타임 허용" 초기 결정을 "머지 = 무조건 배포 + 무중단"으로 대체 - 박스 로컬 nginx 를 고정 프론트(:8090)로 두고 슬롯 컨테이너(blue=18090/green=18091, 127.0.0.1 바인딩)를 upstream 상태 파일 갱신 + reload 로 전환한다 (core deploy 와 같은 패턴, 상태 파일이 서빙 슬롯의 source of truth) - 슬롯에 --memory 640m 를 건다: 박스(t4g.small 1.8G)가 swap 0 이라 blue+green overlap 이 RAM 안에 들어야 한다. 파싱 스파이크 OOM 이 관측되면 실측 재조정 - 레거시 단일 컨테이너(piki-extractor)가 :8090 을 점유한 이행 1회차는 새 슬롯 헬스 통과 후 레거시 제거 - nginx 기동 순서로 처리한다 (수초 공백 1회, 소비자 재시도가 흡수). 이후 배포는 reload 전환이라 무중단 - 새 슬롯 헬스 실패 시 전환 없이 중단해 기존 슬롯이 계속 서빙한다 (자동 롤백) - upstream 포트 추출은 콜론 뒤 숫자만 문다 - 라인에 127.0.0.1 이 있어 무차별 숫자 grep 은 127 을 먼저 문다
📝 WalkthroughWalkthrough배포 워크플로가 ChangesBlue-green 배포
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant Docker
participant Nginx
participant InactiveSlot
participant PreviousSlot
GitHubActions->>Docker: 새 이미지로 비활성 슬롯 실행
GitHubActions->>InactiveSlot: 직접 헬스체크
InactiveSlot-->>GitHubActions: 헬스체크 결과
GitHubActions->>Nginx: upstream 갱신 및 reload/restart
Nginx->>InactiveSlot: :8090 요청 전달
GitHubActions->>Nginx: 최종 경로 검증
GitHubActions->>PreviousSlot: 이전 슬롯 중지 및 삭제
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
infra/nginx/extractor.conf (1)
10-12: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winupstream keepalive 캐시를 설정하십시오.
proxy_http_version 1.1과Connection ""만으로는 upstream idle connection cache가 생성되지 않습니다.keepalive를 추가해야 주석의 연결 재사용 동작이 적용됩니다.제안 변경
upstream piki_extractor { include /etc/nginx/piki-extractor-upstream.conf; + keepalive 32; }배포 대상 Nginx 버전과 실제 동시 요청 수에 맞는
keepalive값을 확인하십시오.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@infra/nginx/extractor.conf` around lines 10 - 12, upstream piki_extractor 블록에 upstream idle connection 재사용을 위한 keepalive 설정을 추가하십시오. 배포 대상 Nginx 버전과 실제 동시 요청 수를 기준으로 적절한 keepalive 값을 정하고, 기존 include 설정은 유지하십시오.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/deploy.yml:
- Around line 206-221: Update the deployment transition around the upstream
state update, nginx validation/reload, and healthcheck to preserve the previous
state before writing the inactive slot. Make the state-file replacement atomic,
and on any validation, reload, or final :8090 healthcheck failure restore the
previous upstream atomically and reload nginx before failing. Move the
piki-extractor stop/remove cleanup until after the final healthcheck succeeds.
---
Nitpick comments:
In `@infra/nginx/extractor.conf`:
- Around line 10-12: upstream piki_extractor 블록에 upstream idle connection 재사용을
위한 keepalive 설정을 추가하십시오. 배포 대상 Nginx 버전과 실제 동시 요청 수를 기준으로 적절한 keepalive 값을 정하고,
기존 include 설정은 유지하십시오.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6a08643e-da0d-4fdc-8c91-a9db7de3c31e
📒 Files selected for processing (2)
.github/workflows/deploy.ymlinfra/nginx/extractor.conf
- nginx -t·reload·최종 헬스체크 어느 단계가 실패해도 이전 upstream 을 원복한다. 원복이 없으면 상태 파일만 새 슬롯을 가리킨 채 남아, 다음 배포가 실제 서빙 슬롯을 비활성으로 오판해 제거한다 (CodeRabbit 리뷰 반영) - 최종 헬스 실패 시 새 슬롯도 정리하고, 구 슬롯 제거는 최종 헬스 통과 뒤에만 수행 - upstream 에 keepalive 4 추가 (nitpick 반영 - location 의 1.1 + Connection 초기화 전제)
Situation
Task
Action
트리거
on: push: branches: [main]추가, workflow_dispatch 는 유지. concurrency 그룹(deploy, cancel 없음)이 연속 머지를 직렬화한다.blue-green 구성
/etc/nginx/piki-extractor-upstream.conf상태 파일이 서빙 슬롯의 source of truth 다. 전환 = 상태 파일 갱신 + nginx reload (core deploy 와 같은 패턴).infra/nginx/extractor.conf가 정본이고 매 배포 박스로 복사된다. proxy read 타임아웃은 호출자(core) read 예산보다 크게 둬 nginx 가 먼저 끊는 층이 되지 않게 했다.메모리 캡
--memory 640m --memory-swap 640m. 박스(t4g.small 1.8G)는 swap 0 이라 blue+green overlap 이 RAM 안에 들어야 한다 (2x640m + Alloy 약 100m + nginx·시스템 < 1.8G, 현 컨테이너 실사용 실측 356Mi). 기존 무제한(호스트 70%) 대비 좁아진 값이라 파싱 스파이크 OOM 이 관측되면 실측으로 재조정한다. cgroup-OOM 은 슬롯 하나로 격리되고 restart 정책이 재기동한다.이행 (1회차 배포)
검토 중 잡은 함정
grep -oE '[0-9]+' | head -1) 그대로 가져오면 안 됐다. core 라인은localhost:8080이지만 여기는127.0.0.1:18090이라 첫 숫자가127로 잡힌다. 콜론 뒤 숫자만 뽑도록 바꿨고, 슬롯 판정 3케이스(부트스트랩·18090·18091)를 로컬 실행으로 검증했다.Result
연관 이슈
Summary by CodeRabbit
배포
서비스 안정성