Skip to content

[FEAT] Dockerfile + ECR 이미지·배포 워크플로 (OIDC · 커밋 SHA 태그) - #7

Merged
hyunj11 merged 1 commit into
developfrom
feat/ai-ecr-deploy
Aug 5, 2026
Merged

[FEAT] Dockerfile + ECR 이미지·배포 워크플로 (OIDC · 커밋 SHA 태그)#7
hyunj11 merged 1 commit into
developfrom
feat/ai-ecr-deploy

Conversation

@dlxodus02

Copy link
Copy Markdown
Contributor

📌 연관 이슈


📝 작업 내용

인프라 결정(Docker Hub → Private ECR z-ai) 반영. 액세스 키·Docker Hub 토큰을 저장하지 않고 GitHub OIDC 로만 인증합니다.

트리거 하는 일
PR docker build 만 (자격증명 없음) — Dockerfile 이 깨졌는지 확인
develop ECR z-ai 로 커밋 SHA 태그 푸시
main 빌드·푸시 + SSM 배포 (tag:Role=ai · /opt/z-ai-worker/deploy.sh)

💡 리뷰 포인트

1. pip 이 아니라 uv — 이게 가장 헷갈릴 부분입니다.

uv sync --locked --no-dev   # requirements.txt 가 없다

pip install -r requirements.txt 로 이미지를 만들면 그런 파일이 없어서 실패합니다. uv0.11.28 로 고정했고, 태그를 검증할 수 없는 외부 이미지에서 COPY 하지 않고 PyPI 고정 버전으로 설치합니다.

2. Immutable 재푸시 대응

같은 태그 재푸시는 실패하므로 두 워크플로 모두 태그 존재를 먼저 확인하고 있으면 건너뜁니다. 워크플로 재실행은 정상 동작인데 그게 빨간불이 되면 사람이 빨간불을 무시하기 시작합니다.

3. HEALTHCHECK 가 /health 인 이유

AI-10(/internal/health)은 X-Internal-Token 이 필요해서 헬스체크로 쓸 수 없습니다 — 토큰을 이미지나 컨테이너 설정에 심어야 합니다. 무인증 /health 를 쓰고, curl 을 설치하지 않으려고 파이썬 표준 라이브러리로 확인합니다.

4. 배포 concurrency 는 cancel-in-progress: false

배포를 중간에 끊으면 컨테이너가 반쯤 교체된 상태로 남습니다. 이미지 빌드(취소 가능)와 다릅니다.

5. 비루트 실행 · .dockerignore.env

uid 1001 로 돕니다. .dockerignore 에서 .env 를 빼는 게 가장 중요합니다 — 운영 비밀값은 SSM Parameter Store 가 주입합니다.

✅ 검증

  • 워크플로 YAML 3개 파싱 확인
  • 이미지가 실제로 쓸 명령을 로컬에서 실행uv sync --locked --no-dev · --no-install-project 둘 다 lock 과 일치. 원복 후 테스트 40개 통과
  • DockerfileCOPY 하는 대상 4개(pyproject.toml·uv.lock·.python-version·app) 존재 확인
  • 액션 태그 존재를 전부 확인 (setup-uv@v9 처럼 major 별칭이 없는 액션이 있어서)

⚠️ docker build 자체는 검증하지 못했습니다 — 로컬에 Docker 데몬이 없습니다. 이 PR 의 build 잡이 그걸 검증합니다. 빨간불이면 그게 첫 신호입니다.

⚠️ 아직 확인 안 된 인프라 전제

  1. AI EC2 에 Role=ai 태그 — 없으면 배포 스텝이 "대상 없음"으로 실패합니다 (ai-cd.yml 에서 명확한 에러 메시지로 끊습니다)
  2. /opt/z-ai-worker/deploy.sh 인자 규약$1=커밋 SHA, $2=전체 이미지 URI 로 넘깁니다. BACKEND deploy.sh 는 SHA 만 받지만 ECR 은 레지스트리 호스트가 필요해서 URI 를 함께 보냅니다. 스크립트가 $2 를 무시해도 무해합니다
  3. 컨테이너 이름·compose — AI EC2 는 Python + Qdrant 두 컨테이너입니다. 컨테이너 교체는 deploy.sh 소관으로 두고 이 워크플로는 SHA 전달까지만 합니다

인프라 결정 반영: Docker Hub 대신 Private ECR z-ai(ap-northeast-2).
액세스 키·Docker Hub 토큰을 저장하지 않고 GitHub OIDC 로만 인증한다.

Dockerfile
  2단계 빌드. 의존성 레이어를 먼저 만들어 소스만 바뀔 때 재설치하지 않는다.
  ⚠️ 이 프로젝트는 pip + requirements.txt 가 아니라 uv + uv.lock 이다 —
     uv sync --locked --no-dev 로 설치하고 .venv 를 실행 스테이지로 복사한다.
  uv 는 0.11.28 로 고정(로컬·CI 와 같은 해석 결과). 태그를 검증할 수 없는 외부
  이미지에서 COPY 하지 않고 PyPI 고정 버전으로 설치한다.
  비루트(uid 1001) 실행. HEALTHCHECK 는 무인증 /health 를 파이썬 표준 라이브러리로
  확인한다 — AI-10(/internal/health)은 토큰이 필요해 헬스체크로 쓸 수 없고,
  curl 을 설치하지 않으려는 이유도 있다.

ai-image.yml
  PR      → docker build 만 (자격증명 없음). Dockerfile 이 깨졌는지 여기서 잡는다.
  develop → ECR 로 커밋 SHA 태그 푸시. latest 는 쓰지 않는다.

ai-cd.yml
  main push · workflow_dispatch → 빌드·푸시 + SSM 배포.
  대상은 tag:Role=ai, 스크립트는 /opt/z-ai-worker/deploy.sh.
  인자 규약 $1=SHA $2=이미지 URI — ECR 은 레지스트리 호스트가 필요해서 URI 를
  함께 넘긴다(스크립트가 $2 를 무시해도 무해).
  concurrency 는 cancel-in-progress:false — 배포를 중간에 끊으면 컨테이너가
  반쯤 교체된 상태로 남는다.

Immutable 대응
  같은 태그 재푸시는 실패하므로, 두 워크플로 모두 태그 존재를 먼저 확인하고
  있으면 건너뛴다. 워크플로 재실행은 정상 동작인데 그게 빨간불이 되면
  사람이 빨간불을 무시하기 시작한다.

액션 버전은 BACKEND cd.yml 과 같은 조합으로 고정했다(같은 OIDC 역할로 검증된 조합).
setup-uv 처럼 major 별칭 태그가 없는 액션이 있어 전부 존재를 확인했다.

검증
  · 워크플로 YAML 3개 파싱 확인
  · 이미지가 쓸 명령을 로컬에서 실행 — uv sync --locked --no-dev(--no-install-project)
    둘 다 lock 과 일치. 원복 후 테스트 40개 통과
  · Dockerfile 이 COPY 하는 대상 4개 존재 확인
  ⚠️ docker build 자체는 로컬 Docker 데몬이 없어 확인하지 못했다 — 이 PR 의
     build 잡이 그걸 검증한다

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

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@dlxodus02, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e7526fe7-8faf-4042-b840-6a3a882df4db

📥 Commits

Reviewing files that changed from the base of the PR and between ee8370b and 470ed00.

📒 Files selected for processing (5)
  • .dockerignore
  • .github/workflows/ai-cd.yml
  • .github/workflows/ai-image.yml
  • Dockerfile
  • README.md

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

@dlxodus02 dlxodus02 added this to the [M1] BE 기능 개발 milestone Aug 5, 2026

@hyunj11 hyunj11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

확인했습니다

@hyunj11
hyunj11 merged commit 91295ed into develop Aug 5, 2026
5 checks passed
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.

[FEAT] Dockerfile + ECR 이미지·배포 워크플로

2 participants