-
Notifications
You must be signed in to change notification settings - Fork 1
Chore/54 CI/CD 파이프라인 안정성 개선 #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough배포 워크플로우 스크립트에서 모든 Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub Actions
participant Server
GitHub Actions->>Server: docker compose ps
GitHub Actions->>Server: docker compose stop
GitHub Actions->>Server: docker compose up -d
GitHub Actions->>Server: docker compose logs
Note over GitHub Actions,Server: PM2 관련 명령어 제거됨
Possibly related PRs
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
.github/workflows/deploy.yml (4)
126-130: YAML Lint 오류: 130 행의 후행 공백 제거 필요
yamllint가 지적한 트레일링 스페이스가 그대로 남아 있으면 파이프라인이 실패할 수 있습니다. 불필요한 공백을 제거해 주세요.- echo "Current: $CURRENT_IMAGE" > ~/deployments/previous-version.txt + echo "Current: $CURRENT_IMAGE" > ~/deployments/previous-version.txt
132-134:docker compose down시 orphan 컨테이너 정리 옵션 추가 권장현재 중지 명령은 잔여 컨테이너를 남길 수 있습니다.
--remove-orphans를 함께 사용하면 예기치 못한 충돌을 예방할 수 있습니다.- docker compose down || true + docker compose down --remove-orphans || true
140-144: 최신 이미지를 확실히 사용하려면--pull always옵션 추가태그가 같은 이미지를 캐시에서 가져오는 상황을 방지하려면
docker compose up시--pull always를 붙여 최신 이미지를 강제하는 것이 안전합니다.- docker compose up -d + docker compose up -d --pull always
157-160: 로그 조회 가독성 개선 및 프리픽스 제거 고려서비스명을 앞에 두고
--no-log-prefix옵션을 추가하면 출력이 한눈에 들어옵니다.- docker compose logs --tail 50 nextjs + docker compose logs nextjs --tail 50 --no-log-prefix
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/deploy.yml(3 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/deploy.yml
[error] 130-130: trailing spaces
(trailing-spaces)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
.github/workflows/deploy.yml (1)
108-114: IMAGE_URL‧GIT_SHA가 원격에 전달되지 않아docker pull단계에서 실패합니다
<< 'ENDSSH'형태의 히어독은 로컬 변수 확장을 차단하므로, 원격 세션에는 IMAGE_URL/GIT_SHA가 정의되지 않습니다. 이후${IMAGE_URL}참조(112·137·142행 등)가 빈 값이어서 배포가 즉시 실패합니다.- ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << 'ENDSSH' + ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << ENDSSH + # 로컬에서 받은 값을 원격 세션에 주입 + export IMAGE_URL="${IMAGE_URL}" + export GIT_SHA="${GIT_SHA}"ENDSSH 뒤쪽은 그대로 유지하면 됩니다.
이 방식이 어렵다면ssh옵션-o SendEnv=를 쓰거나, 명령어 인라인 전달(ssh host "IMAGE_URL=$IMAGE_URL ...")도 가능합니다.
🧹 Nitpick comments (3)
.github/workflows/deploy.yml (3)
126-130:docker compose ps … | xargs …구문이 깨질 수 있으며 YAMLLint 경고(공백)도 존재합니다
- 서비스명이
nextjs로 하드코딩되어 있어docker compose파일 변경 시 자동 롤백 기능이 깨집니다.--services혹은 환경변수 기반으로 이름을 주입해 두는 편이 안전합니다.xargs앞에서 파이프가 실패해도set -e가 무력화됩니다.set -o pipefail을 함께 지정하거나|| true대신 명시적 오류 처리를 권장합니다.- 130행 끝에 불필요한 공백이 있어 YAMLLint가 오류(trailing-spaces)를 보고합니다.
예시:
- CURRENT_IMAGE=$(docker compose ps -q nextjs | xargs docker inspect -f '{{.Config.Image}}' 2>/dev/null || echo "none") + set -o pipefail + SERVICE_NAME=${SERVICE_NAME:-nextjs} + CURRENT_IMAGE=$(docker compose ps -q "$SERVICE_NAME" | \ + xargs -r docker inspect -f '{{.Config.Image}}' 2>/dev/null || echo "none")
133-134:docker compose down시 고아 컨테이너 및 볼륨 정리 플래그를 함께 사용해 주세요
--remove-orphans와 상황에 따라--volumes를 추가해 두면 이전 버전에서 남은 불필요한 컨테이너·볼륨이 깔끔히 정리됩니다.- docker compose down || true + docker compose down --remove-orphans --volumes || true
159-160: 장애 분석을 위해 로그 출력 뒤 바로 실패 코드를 전달하도록 순서를 단순화할 수 있습니다
docker compose logs … && exit 1형태면 로그가 찍힌 뒤 정확한 실패 코드가 유지됩니다. 현 구조도 동작하나 명시적 연쇄가 가독성에 더 좋습니다.- docker compose logs --tail 50 nextjs - exit 1 + docker compose logs --tail 50 nextjs && exit 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/deploy.yml(3 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/deploy.yml
[error] 130-130: trailing spaces
(trailing-spaces)
📌 변경 사항 개요
배포 워크플로우(
deploy.yml)의 안정성을 개선하고, 서버에 설정했던 임시 조치들을 제거하여 파이프라인을 최종적으로 완성했습니다.📝 상세 내용
1.
docker-compose명령어 호환성 해결문제점: 기존 워크플로우는 구버전 명령어인
docker-compose를 사용하고 있어, 최신docker compose(공백)가 설치된 서버와 호환되지 않았습니다. 이는 서버에 직접 심볼릭 링크를 생성하는 임시 조치로 해결한 상태였습니다.개선사항:
deploy.yml파일 내 모든 관련 명령어를docker compose로 수정하고, 더 이상 서버의 임시 조치에 의존하지 않도록 변경했습니다.2. 불필요한
pm2정리 코드 제거pm2관련 명령어들을 스크립트에서 모두 제거하였습니다.🔗 관련 이슈
🖼️ 스크린샷(선택사항)
💡 참고 사항
docker-compose심볼릭 링크를 제거할 예정Summary by CodeRabbit
docker-compose명령어를docker compose로 교체하였습니다.