[chore] 배포 이미지가 latest로 통일되던 문제 수정 및 전체 배포 로직 개선#1213
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning
|
| Cohort / File(s) | Summary |
|---|---|
GitHub Actions 배포 워크플로우 .github/workflows/oracle_server_cd_develop.yml |
배포 이미지를 latest에서 commit SHA 기반의 특정 버전(DOCKER_IMAGE_DEV:${{ github.sha }})으로 변경하고, SSH 배포 단계에 120초 타임아웃 추가. 단계 이름을 "Update Container on VM"에서 "Deploy to Oracle VM"으로 변경하고 배포 로직에 주석과 로깅 추가. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
- [feature] 오라클 클라우드 CI/CD 구축 #518: 동일한 GitHub Actions 워크플로우 파일 수정으로, 배포 단계의 이미지 태깅, 풀링, SSH 기반 배포 흐름 변경 관련.
Suggested labels
💾 BE, 📦 CI/CD
Suggested reviewers
- SeongHoonC
- seongwon030
- PororoAndFriends
- Due-IT
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The PR title clearly describes the main changes: fixing the deployment image tagging issue (latest → commit hash) and improving the overall deployment logic. |
| Linked Issues check | ✅ Passed | The code changes align with MOA-662 objectives: replacing 'latest' tag with commit hash (github.sha) for unique image identification and improving deployment logic with timeout adjustments. |
| Out of Scope Changes check | ✅ Passed | All changes in the workflow file are directly related to the linked issue objectives: image tagging strategy, deployment timeout, and deployment process improvements. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
feature/#1212-fix-deploy-MOA-662
Tip
Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.
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 @coderabbitai help to get the list of available commands and usage tips.
Test Results99 tests 99 ✅ 19s ⏱️ Results for commit b8a7e58. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.github/workflows/oracle_server_cd_develop.yml (1)
89-89:appleboy/ssh-action@master는 부동 참조(floating ref)로 공급망 보안 위험이 있습니다.
@master를 사용하면 업스트림 리포지토리에 악성 코드가 커밋되거나 의도치 않은 변경이 생겼을 때 즉시 영향을 받습니다. 특정 버전 태그나 커밋 SHA로 고정하는 것을 권장합니다.🔒 appleboy/ssh-action 버전 고정 예시
- uses: appleboy/ssh-action@master + uses: appleboy/ssh-action@v1.2.0🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/oracle_server_cd_develop.yml at line 89, The workflow uses a floating ref "uses: appleboy/ssh-action@master" which is a supply-chain risk; update that "uses" entry to pin a specific released tag or commit SHA (e.g., replace appleboy/ssh-action@master with appleboy/ssh-action@v<version> or @<commit-sha>) so the action is immutable and repeatable. Locate the "uses: appleboy/ssh-action@master" line in the workflow and change it to a fixed tag or SHA, and optionally add a brief comment noting the chosen pinned version.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/oracle_server_cd_develop.yml:
- Around line 104-105: The workflow currently runs the command `docker pull
$TARGET_IMAGE` without failing the job on error; update the script so a failed
`docker pull $TARGET_IMAGE` aborts the run — either add `set -e` near the top of
the shell step or add explicit error handling immediately after `docker pull
$TARGET_IMAGE` (e.g., check the exit status and `exit 1` if non-zero) to prevent
continuing to steps that expect a valid image or `deploy.sh`.
- Around line 116-117: The workflow currently runs "docker image prune -f" which
only removes dangling images and will not clean up SHA-tagged images like
DOCKER_IMAGE_DEV:${{ github.sha }}; update this step to either run "docker image
prune -af" to remove all unused images after a successful deploy or replace it
with a selective cleanup that lists and removes old images for the same
repository while preserving the currently deployed tag (DOCKER_IMAGE_DEV:${{
github.sha }}), ensuring you reference the existing docker image prune
invocation when making the change.
- Around line 95-96: The workflow uses the SSH "timeout" key but the intended
control is over remote command execution time; change or add the
"command_timeout" parameter (e.g., set command_timeout: 120s or a larger value)
so long-running operations like docker pull and deploy.sh are given enough time,
and keep "timeout" only for SSH connection establishment if desired; update the
YAML keys "timeout" -> "command_timeout" (or add "command_timeout" alongside
"timeout") accordingly.
---
Nitpick comments:
In @.github/workflows/oracle_server_cd_develop.yml:
- Line 89: The workflow uses a floating ref "uses: appleboy/ssh-action@master"
which is a supply-chain risk; update that "uses" entry to pin a specific
released tag or commit SHA (e.g., replace appleboy/ssh-action@master with
appleboy/ssh-action@v<version> or @<commit-sha>) so the action is immutable and
repeatable. Locate the "uses: appleboy/ssh-action@master" line in the workflow
and change it to a fixed tag or SHA, and optionally add a brief comment noting
the chosen pinned version.
| # 2. 명시된 버전의 이미지를 Pull (latest가 아니므로 캐시 문제 없음) | ||
| docker pull $TARGET_IMAGE |
There was a problem hiding this comment.
docker pull 실패 시 스크립트가 중단되지 않아 잘못된 이미지로 배포될 수 있습니다.
docker pull이 실패해도 스크립트가 계속 실행되어 deploy.sh가 존재하지 않거나 이전 버전의 이미지를 사용할 수 있습니다. 스크립트 상단에 set -e를 추가하거나 명시적 에러 처리를 적용해야 합니다.
🛠️ `set -e` 또는 명시적 에러 처리 추가
script: |
+ set -e
# 1. 사용할 이미지 태그를 변수로 지정 (latest가 아닌 github.sha 사용)
# github.sha는 빌드 잡에서 생성한 태그와 동일한 값입니다.
TARGET_IMAGE="${{ secrets.DOCKER_IMAGE_DEV }}:${{ github.sha }}"
echo "Deploying target image: $TARGET_IMAGE"
# 2. 명시된 버전의 이미지를 Pull (latest가 아니므로 캐시 문제 없음)
docker pull $TARGET_IMAGE🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/oracle_server_cd_develop.yml around lines 104 - 105, The
workflow currently runs the command `docker pull $TARGET_IMAGE` without failing
the job on error; update the script so a failed `docker pull $TARGET_IMAGE`
aborts the run — either add `set -e` near the top of the shell step or add
explicit error handling immediately after `docker pull $TARGET_IMAGE` (e.g.,
check the exit status and `exit 1` if non-zero) to prevent continuing to steps
that expect a valid image or `deploy.sh`.
| # 5. 불필요한 이미지 정리 (공간 확보) | ||
| docker image prune -f |
There was a problem hiding this comment.
docker image prune -f만으로는 SHA 태그 이미지가 정리되지 않아 디스크가 점진적으로 고갈됩니다.
-f(기본)는 dangling 이미지(태그 없음)만 제거합니다. 이번 PR에서 각 배포마다 고유한 SHA 태그(DOCKER_IMAGE_DEV:${{ github.sha }})가 붙은 이미지가 생성되는데, 이 이미지는 dangling 상태가 아니므로 -f만으로는 삭제되지 않습니다. 배포가 반복될수록 구 버전 SHA 이미지가 서버에 무한 누적되어 결국 디스크 부족으로 장애가 발생할 수 있습니다.
이전 코드의 docker image prune -af(사용 중이지 않은 모든 이미지 제거)로 복원하거나, 현재 배포된 이미지를 제외한 구 버전 이미지를 명시적으로 제거하는 방식을 사용해야 합니다.
🛠️ 구 버전 이미지 정리 방법
방법 1: 사용 중이지 않은 모든 이미지 제거 (deploy.sh가 컨테이너를 정상 구동한 뒤 실행되는 경우 안전)
- # 5. 불필요한 이미지 정리 (공간 확보)
- docker image prune -f
+ # 5. 불필요한 이미지 정리 (공간 확보)
+ # 현재 실행 중인 컨테이너가 사용하는 이미지는 제거되지 않음
+ docker image prune -af방법 2: 해당 리포지토리의 구 버전 이미지만 선택적으로 제거
- # 5. 불필요한 이미지 정리 (공간 확보)
- docker image prune -f
+ # 5. 현재 배포 이미지를 제외한 구 버전 이미지 제거
+ docker images --format '{{.Repository}}:{{.Tag}} {{.ID}}' \
+ | grep "^${{ secrets.DOCKER_IMAGE_DEV }}:" \
+ | grep -v "$TARGET_IMAGE" \
+ | awk '{print $2}' \
+ | xargs -r docker rmi -f || true📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # 5. 불필요한 이미지 정리 (공간 확보) | |
| docker image prune -f | |
| # 5. 불필요한 이미지 정리 (공간 확보) | |
| # 현재 실행 중인 컨테이너가 사용하는 이미지는 제거되지 않음 | |
| docker image prune -af |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/oracle_server_cd_develop.yml around lines 116 - 117, The
workflow currently runs "docker image prune -f" which only removes dangling
images and will not clean up SHA-tagged images like DOCKER_IMAGE_DEV:${{
github.sha }}; update this step to either run "docker image prune -af" to remove
all unused images after a successful deploy or replace it with a selective
cleanup that lists and removes old images for the same repository while
preserving the currently deployed tag (DOCKER_IMAGE_DEV:${{ github.sha }}),
ensuring you reference the existing docker image prune invocation when making
the change.
There was a problem hiding this comment.
@lepitaaar, 네, 맞습니다! SHA 태그를 사용하는 방식으로 변경하면서 이미지 정리 전략도 함께 조정해야 합니다.
어떤 방식을 선호하시나요?
옵션 1: docker image prune -af 사용 (간단하고 안전)
- 현재 실행 중인 컨테이너가 사용하는 이미지는 자동으로 보호됨
- 다른 프로젝트/이미지가 같은 서버에 있다면 해당 이미지도 정리될 수 있음
옵션 2: 선택적 정리 (더 정밀한 제어)
- 현재 프로젝트의 구 버전 SHA 이미지만 정리
- 다른 프로젝트/이미지에 영향 없음
- 스크립트가 약간 복잡해짐
어떤 방식으로 진행하시겠습니까? 원하시는 방식을 알려주시면 코드 변경을 준비해드리겠습니다! 🚀
| # 5. 불필요한 이미지 정리 (공간 확보) | ||
| docker image prune -f |
#️⃣연관된 이슈
#1212
📝작업 내용
어느날 개발서버에 최신 형상이 반영되지 않던 문제 발견.
배포이미지 태그가 latest로 고정되어있던 문제 수정.
배포 이미지 관리를 쉽게 하도록 커밋 해시값을 이용하도록 변경.
가끔 네트워크 이슈나 빌드 중에 이슈로 latest가 겹쳐서 최신 이미지가 옛날 버전 갈 수가 있는데 unique한 이름을 부여해서 원천 차단.
추가로 프로덕션 서버랑 개발섭 deploy.sh 도커컴포즈 헬스체크 타임아웃을 개발섭 60초, 배포섭 20초 -> 120초로 증가.
중점적으로 리뷰받고 싶은 부분(선택)
논의하고 싶은 부분(선택)
🫡 참고사항
Summary by CodeRabbit
릴리스 노트