fix(ci): Redis 컨테이너 가드가 배포를 죽이던 문제 수정 - #82
Merged
Conversation
두 번째 배포부터 이름 충돌로 실패했다.
Error: Conflict. The container name "/redis" is already in use
가드를 이렇게 썼다.
if [ -z "$(docker ps -q -f name=^redis$)" ]; then
이 스크립트는 인용하지 않은 heredoc(<< EOF)으로 SSH 에 넘어간다. 그래서 $(...) 가
EC2 가 아니라 GitHub 러너에서 평가된다. 러너에는 redis 컨테이너가 없으니 결과가 늘
비어 조건이 항상 참이 되고, EC2 에 이미 떠 있는 컨테이너를 다시 만들려다 죽는다.
같은 파일의 기존 코드는 \$(...) 로 이스케이프해 EC2 에서 평가되게 해 두었는데,
Redis 를 추가하면서 그 규칙을 따르지 않았다. 처음 배포에서는 컨테이너가 없어
통과했고, 그다음 배포에서 드러났다.
조건문에서 명령 치환을 아예 걷어낸다. docker start 는 컨테이너가 있으면 멈춰 있어도
성공하고 없으면 실패하므로, 그것만으로 있으면 재사용하고 없으면 만드는 동작이 된다.
배포가 컨테이너 교체 전 단계에서 멈춰 dev 는 이전 이미지로 계속 떠 있었다.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#78 배포가 실패했다. 커뮤니티 코드 문제가 아니라 내가 Redis 를 추가하며 넣은 가드 버그다.
원인
이 스크립트는 인용하지 않은 heredoc(
<< EOF) 으로 SSH 에 넘어간다. 그래서$(...)가EC2 가 아니라 GitHub 러너에서 평가된다. 러너에는 redis 컨테이너가 없으니 결과가 늘 비어
조건이 항상 참이 되고, EC2 에 이미 떠 있는 컨테이너를 다시 만들려다 죽는다.
같은 파일의 기존 코드는
\$(...)로 이스케이프해 EC2 에서 평가되게 해 두었다. Redis 를추가하면서 그 규칙을 따르지 않았다. 첫 배포(#81)에서는 컨테이너가 없어 통과했고 그다음
배포에서 드러났다.
수정
조건문에서 명령 치환을 걷어낸다.
docker start는 컨테이너가 있으면 멈춰 있어도 성공하고 없으면 실패한다. 그것만으로있으면 재사용, 없으면 생성이 된다. 이스케이프 규칙에 기대지 않아 같은 실수가 반복되지 않는다.
영향
배포는 컨테이너 교체 전 단계에서 멈췄다. dev 는 이전 이미지로 계속 떠 있었고 API 도
정상이었다. 다만 #78 커뮤니티 코드가 아직 배포되지 않았다. 이 PR 이 머지되면 함께 올라간다.
🤖 Generated with Claude Code