Skip to content

chore(ci): main 푸시 시 이미지 빌드 후 EC2 배포 자동화 #79 - #96

Open
tlgms wants to merge 1 commit into
developfrom
chore/79-cd-deploy
Open

chore(ci): main 푸시 시 이미지 빌드 후 EC2 배포 자동화 #79#96
tlgms wants to merge 1 commit into
developfrom
chore/79-cd-deploy

Conversation

@tlgms

@tlgms tlgms commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 기존 수동 이미지 빌드 워크플로(deploy.yml, workflow_dispatch 전용)를 빌드 → 푸시 → 배포 → 헬스체크로 이어지는 CD 파이프라인으로 확장합니다.
  • main 푸시 시 자동 실행되며, EC2에 SSH로 접속해 docker compose pull && up -d/actuator/health 를 확인합니다.

Related Issue

Important

#79@wlyoon921 님께 할당되어 있습니다. 요청을 받아 먼저 초안을 올렸으니, 의도와 다른 부분이 있으면 편하게 되돌리거나 가져가주세요.

Scope

  • 영향 범위: .github/workflows/deploy.yml 1개 파일
  • 애플리케이션 코드 변경 없음

Change Type

  • Refactor
  • Dependency update
  • Config / infra change
  • Tooling / CI

⚠️ 세부 정보는 비워두었습니다 — 배포 전 설정 필요

접속 정보를 몰라 전부 미설정 상태로 두었습니다. 아래를 채워야 실제 배포가 동작합니다.
DEPLOY_HOSTS 가 비어 있으면 deploy 잡을 통째로 건너뛰므로, 설정 전까지 main 푸시가 빨갛게 실패하지는 않습니다. (이미지 빌드/푸시는 설정 없이도 동작합니다.)

Settings → Secrets and variables → Actions → Secrets

이름
DEPLOY_SSH_KEY EC2 접속용 SSH private key 전체 내용
DEPLOY_KNOWN_HOSTS ssh-keyscan <host> 출력을 EC2 3대분 합친 값

Settings → Secrets and variables → Actions → Variables

이름 예시
DEPLOY_HOSTS 대상 EC2 호스트 JSON 배열 ["10.0.1.10", "10.0.1.11", "10.0.1.12"]
DEPLOY_USER SSH 사용자명 ubuntu
DEPLOY_PATH EC2에서 docker-compose.yml 이 있는 디렉터리 /opt/entrydsm
HEALTHCHECK_URL (선택) 미설정 시 기본값 사용 http://localhost:8080/actuator/health

설계 메모

EC2에서 재빌드하지 않고 GHCR 이미지를 pull 합니다.
#79 본문에는 "EC2에서 Docker 이미지를 다시 빌드"라고 되어 있지만, 이미 deploy.yml이 GHCR로 푸시하고 docker-compose.ymlghcr.io/entrydsm/entrydsm-*:latest 를 참조하는 구조라 그대로 이었습니다. EC2에서 Bazel 모노레포를 빌드하면 시간과 메모리 부담이 큽니다. 의도가 달랐다면 알려주세요.

커밋 SHA 태그를 함께 푸시합니다.
지금은 :latest 만 올라가서 롤백도 추적도 불가능합니다. :<sha> 를 추가해 특정 커밋으로 되돌릴 수 있게 했습니다. compose는 그대로 :latest 를 봅니다.

헬스체크는 EC2 안에서 실행합니다.
러너에서 EC2로 직접 HTTP를 쏘면 보안 그룹을 열어야 하므로, SSH로 들어가 curl localhost:8080 을 호출합니다. 컨테이너 기동을 기다리기 위해 5초 간격 30회(최대 150초) 재시도합니다.

호스트 3대는 matrix로 병렬 처리하고 fail-fast: false 입니다.
한 대가 실패해도 나머지는 계속 진행합니다. 순차 배포(롤링)가 필요하면 max-parallel: 1 을 추가하면 됩니다.

Risk

Warning

이 워크플로의 deploy 잡은 한 번도 실행된 적이 없습니다. EC2와 시크릿에 접근할 수 없어 검증이 불가능했습니다. YAML 문법과 잡 구조만 확인한 상태이며, 첫 실행은 반드시 workflow_dispatch 로 수동 실행해 확인해주세요.

  • 검증한 것: YAML 파싱, /actuator/health 노출 여부(전 서비스 include: health,info + probes 활성 확인)
  • 검증하지 못한 것: SSH 접속, docker compose 동작, 헬스체크 응답, 배포 경로

그 외 짚어둘 점

  • main 푸시 시 테스트를 다시 돌리지 않습니다. 브랜치 보호로 PR 단계에서 CI(chore(ci): PR 단위 Bazel 빌드/테스트 자동화 #93 #95)를 required check로 걸어두는 것을 전제로 합니다.
  • :latest 를 pull 하는 방식이라 배포 시점에 따라 이미지가 달라질 수 있습니다. 완전한 재현성이 필요하면 docker-compose.yml:${TAG:-latest} 로 바꾸고 SHA를 넘기는 방식이 낫습니다. 지금은 범위 밖으로 두었습니다.

Checklist

  • No functional changes
  • CI / build verified — deploy 잡은 검증 불가 (위 Risk 참고)

🤖 Generated with Claude Code

기존 수동 이미지 빌드 워크플로를 배포까지 이어지는 CD 파이프라인으로 확장한다.

- main 푸시와 workflow_dispatch에서 실행
- 롤백/추적을 위해 커밋 SHA 태그를 함께 푸시
- EC2에 SSH로 접속해 docker compose pull/up 후 /actuator/health 확인
- 접속 정보는 secrets/vars로 분리하고 미설정 시 deploy 잡을 건너뜀

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ready-for-review
🚫 Excluded labels (none allowed) (2)
  • wip
  • do-not-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 6a7c63d6-27e9-4dc7-a232-ab5ad1f3fc03

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Comment @coderabbitai help to get the list of available commands.

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.

CI/CD 구축

2 participants