-
Notifications
You must be signed in to change notification settings - Fork 3
[chore] 배포 이미지가 latest로 통일되던 문제 수정 및 전체 배포 로직 개선 #1213
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -85,20 +85,33 @@ jobs: | |||||||||||
| needs: build | ||||||||||||
|
|
||||||||||||
| steps: | ||||||||||||
| # oracle ssh 접속 후 배포 | ||||||||||||
| - name: Update Container on VM | ||||||||||||
| - name: Deploy to Oracle VM | ||||||||||||
| uses: appleboy/ssh-action@master | ||||||||||||
| with: | ||||||||||||
| host: ${{ secrets.ORACLE_INSTANCE_DEV_IP }} | ||||||||||||
| username: ${{ secrets.ORACLE_INSTANCE_USER }} | ||||||||||||
| key: ${{ secrets.ORACLE_INSTANCE_DEV_PRIVATE_KEY }} | ||||||||||||
| port: ${{ secrets.ORACLE_INSTANCE_DEV_PORT }} | ||||||||||||
| # 타임아웃 설정 (이미지 pull 시간이 길어질 경우 대비) | ||||||||||||
| timeout: 120s | ||||||||||||
| script: | | ||||||||||||
| docker pull ${{ secrets.DOCKER_IMAGE_DEV }}:latest | ||||||||||||
| # 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 | ||||||||||||
|
Comment on lines
+104
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🛠️ `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 |
||||||||||||
|
|
||||||||||||
| # 3. 환경 변수 설정 | ||||||||||||
| export USERNAME=${{ secrets.ORACLE_INSTANCE_USER }} | ||||||||||||
| export DOCKER_APP_IMAGE=${{ secrets.DOCKER_IMAGE_DEV }}:latest | ||||||||||||
| export DOCKER_APP_IMAGE=$TARGET_IMAGE | ||||||||||||
|
|
||||||||||||
| # 4. 배포 스크립트 실행 | ||||||||||||
| # 주의: deploy.sh 내부에서 'docker run ... $DOCKER_APP_IMAGE'를 사용하도록 작성되어 있어야 합니다. | ||||||||||||
| sudo chmod +x /home/${{ secrets.ORACLE_INSTANCE_USER }}/deploy.sh | ||||||||||||
| sudo -E /home/${{ secrets.ORACLE_INSTANCE_USER }}/deploy.sh | ||||||||||||
|
|
||||||||||||
| docker image prune -af | ||||||||||||
| # 5. 불필요한 이미지 정리 (공간 확보) | ||||||||||||
| docker image prune -f | ||||||||||||
|
Comment on lines
+116
to
+117
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
이전 코드의 🛠️ 구 버전 이미지 정리 방법방법 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
Suggested change
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요건 필요할 수 있겠네요
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
어떤 방식을 선호하시나요? 옵션 1:
옵션 2: 선택적 정리 (더 정밀한 제어)
어떤 방식으로 진행하시겠습니까? 원하시는 방식을 알려주시면 코드 변경을 준비해드리겠습니다! 🚀 |
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.