Skip to content

Conversation

@oxdjww
Copy link
Contributor

@oxdjww oxdjww commented Apr 30, 2025

Summary by CodeRabbit

  • Chores
    • 배포 스크립트가 환경 변수 확인, 작업 정의 자동 업데이트, 진행 상황 로깅 등으로 더욱 견고하게 개선되었습니다.
    • ECS 서비스가 새로운 이미지로 자동으로 배포되도록 프로세스가 강화되었습니다.

@oxdjww oxdjww self-assigned this Apr 30, 2025
@coderabbitai
Copy link

coderabbitai bot commented Apr 30, 2025

Walkthrough

이 변경 사항은 배포 자동화 스크립트인 deploy-prod.sh의 기능을 대폭 확장합니다. 스크립트는 이제 필수 환경 변수(BACKEND_IMAGE, AWS_DEFAULT_REGION)의 존재를 먼저 확인하고, 누락 시 즉시 종료합니다. ECS 클러스터와 서비스 이름을 변수로 정의하며, 현재 서비스의 태스크 정의 ARN을 조회한 뒤 해당 태스크 정의의 JSON을 가져옵니다. 이 JSON에서 메타데이터를 제거하고, 컨테이너 이미지를 새 BACKEND_IMAGE로 변경한 후, 이를 이용해 새로운 태스크 정의 리비전을 등록하고, 서비스가 이 리비전을 사용하도록 업데이트합니다. 진행 상황과 주요 값은 echo로 출력됩니다.

Changes

파일 경로 변경 요약
deploy/deploy-prod.sh 환경 변수 체크, 변수화, 태스크 정의 ARN 및 JSON 처리, 이미지 업데이트, 신규 태스크 정의 등록 및 서비스 업데이트, 로그 메시지 추가 등 배포 자동화 로직 대폭 강화

Poem

배포 토끼가 깡충깡충 뛰어
변수도 확인, 이미지도 바꿔
태스크 정의 새로 등록하고
서비스도 척척 업데이트해
로그로 소식 전하며
AWS 위에서 춤추네
오늘도 무사히 배포 완료! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@oxdjww oxdjww merged commit 268c1d4 into main Apr 30, 2025
1 of 2 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
deploy/deploy-prod.sh (1)

9-11: ECS 클러스터 및 서비스 이름 하드코딩 검토
현재 스크립트 내 ECS_CLUSTERECS_SERVICE를 고정값으로 설정하고 있습니다. 테스트나 다른 환경에서 재사용성을 높이려면 환경 변수나 스크립트 인수로 오버라이드할 수 있도록 개선을 고려해 보세요.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a18e73 and f7226f3.

📒 Files selected for processing (1)
  • deploy/deploy-prod.sh (1 hunks)
🔇 Additional comments (7)
deploy/deploy-prod.sh (7)

4-7: 필수 환경 변수 검증: 파라미터 익스팬션 사용
BACKEND_IMAGEAWS_DEFAULT_REGION이 미설정 시 스크립트가 즉시 종료되어 조기 실패를 보장합니다.


14-14: 배포 시작 로깅
echo "🔧 Deploying image → $BACKEND_IMAGE" 로 배포 대상 이미지를 명확히 출력하는 것은 디버깅 및 모니터링에 유용합니다.


16-22: 현재 Task Definition ARN 조회 구현 적절
aws ecs describe-services--query 'services[0].taskDefinition' 조합으로 현재 서비스의 Task Definition ARN을 정확히 가져오고 있습니다. 오류 시 set -e에 의해 스크립트가 중단됩니다.


24-28: Task Definition JSON 조회 로직 확인
aws ecs describe-task-definition --query 'taskDefinition'을 사용해 필요한 JSON만 가져오는 흐름이 효율적이며, AWS_DEFAULT_REGION 환경변수로 region이 자동 설정되므로 별도 플래그 없이도 동작합니다.


36-41: 새 Task Definition 리비전 등록 로직 확인
aws ecs register-task-definition --cli-input-json로 JSON을 입력받아 새로운 리비전을 등록하고, ARN을 추출해 로그로 출력하는 흐름이 명확합니다.


43-49: 서비스 업데이트 명령 구성 적절
aws ecs update-service--task-definition, --force-new-deployment, --region을 포함하여 강제 재배포를 수행하는 부분이 올바르게 구현되었습니다.


52-52: 최종 배포 완료 로깅
echo "✅ Deployment triggered!"로 스크립트 완료 시점을 명확히 알리는 로그를 추가한 것은 사용자 경험을 높입니다.

Comment on lines +30 to +34
# 3) register-task-definition 에 넘길 JSON로 정리
TD_REG_INPUT=$(echo "$TD_JSON" | jq \
'del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy)
| .containerDefinitions[0].image = "'"$BACKEND_IMAGE"'"'
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

jq 변수 인젝션 방식 개선 제안
현재 문자열 연결로 이미지를 삽입하고 있는데, 이미지 이름에 특수문자가 포함되면 JQ 쿼리가 깨질 수 있습니다. 아래처럼 --arg 옵션을 활용해 변수를 안전하게 전달하세요.

- TD_REG_INPUT=$(echo "$TD_JSON" | jq \
-   'del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy)
-    | .containerDefinitions[0].image = "'"$BACKEND_IMAGE"'"'
- )
+ TD_REG_INPUT=$(echo "$TD_JSON" | jq --arg IMAGE "$BACKEND_IMAGE" \
+   'del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy)
+    | .containerDefinitions[0].image = $IMAGE'
+ )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants