-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/109 빌드 시점에 환경 변수를 주입하여 API 경로 오류 수정 #110
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
Conversation
WalkthroughDocker 빌드 및 배포 워크플로우에서 환경 변수 주입 방식을 변경했습니다. 여러 환경 변수를 하나의 build-arg( Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub Actions
participant Docker Build
participant Application
GitHub Actions->>Docker Build: docker build --build-arg BUILD_ENV_VARS="..."
Docker Build->>Dockerfile: ARG BUILD_ENV_VARS
Dockerfile->>Dockerfile: BUILD_ENV_VARS를 .env.production에 저장
Docker Build->>Application: .env.production 파일 포함된 이미지 생성
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes(해당 사항 없음) Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/deploy.yml(1 hunks)Dockerfile(1 hunks)
🧰 Additional context used
🪛 Hadolint (2.12.0)
Dockerfile
[warning] 35-35: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
(DL4006)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Code Quality Check
🔇 Additional comments (2)
Dockerfile (1)
37-40:.env.production파일이 러너(stage 3)로 복사되지 않습니다Next.js 빌드에만 필요하다면 문제없지만, 런타임에서도 동일 파일을 참조한다면
COPY --from=builder .env.production ./이 누락돼 컨테이너 실행 시 환경값이 사라집니다. 요구 사항을 다시 확인해 주세요..github/workflows/deploy.yml (1)
77-80:BUILD_ENV_VARS인코딩 확인 필요여러 시크릿을 공백으로 연결해 하나의 build-arg로 넘기고 있습니다.
GitHub Actions → Docker CLI → Dockerfile 경로를 거치면서 다음 사항을 반드시 검증하세요.
- 각 시크릿이 비어 있거나 포함되지 않을 때 전체 문자열 구성 실패 여부
&,$,\n등 특수문자 이스케이프 여부- 빌드 로그에 시크릿 값이 노출되지 않는지
자동 검증 스크립트를 추가하거나 최소한 개발 브랜치에서 수동 테스트를 권장합니다.
| # 빌드 시점에 주입될 환경 변수 선언 | ||
| ARG BUILD_ENV_VARS | ||
|
|
||
| # 전달받은 ARG 환경 변수를 .env.production 파일에 저장 | ||
| RUN echo "$BUILD_ENV_VARS" | tr ' ' '\n' > .env.production | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RUN echo … | tr 명령에 pipefail 옵션을 지정하세요
알파인 busybox sh에서는 파이프 왼쪽 명령이 실패해도 전체 RUN이 성공으로 간주됩니다.
빌드 시점에 .env.production 생성이 실패해도 무시될 수 있으므로 SHELL 지시어로 -o pipefail을 켜 주는 편이 안전합니다.
+# 파이프 오류 전파
+SHELL ["/bin/ash", "-eo", "pipefail", "-c"]또는 RUN set -o pipefail && echo "$BUILD_ENV_VARS" | tr ' ' '\n' > .env.production 형태로 한 줄에 넣을 수도 있습니다.
📝 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.
| # 빌드 시점에 주입될 환경 변수 선언 | |
| ARG BUILD_ENV_VARS | |
| # 전달받은 ARG 환경 변수를 .env.production 파일에 저장 | |
| RUN echo "$BUILD_ENV_VARS" | tr ' ' '\n' > .env.production | |
| # 빌드 시점에 주입될 환경 변수 선언 | |
| ARG BUILD_ENV_VARS | |
| # 파이프 오류 전파 | |
| SHELL ["/bin/ash", "-eo", "pipefail", "-c"] | |
| # 전달받은 ARG 환경 변수를 .env.production 파일에 저장 | |
| RUN echo "$BUILD_ENV_VARS" | tr ' ' '\n' > .env.production |
🧰 Tools
🪛 Hadolint (2.12.0)
[warning] 35-35: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
(DL4006)
🤖 Prompt for AI Agents
In Dockerfile lines 31 to 36, the RUN command uses a pipe but does not enable
the pipefail option, so failures in the first command may be ignored. Fix this
by adding the shell option -o pipefail either by setting a SHELL directive with
this option before the RUN command or by prefixing the RUN command with 'set -o
pipefail &&' to ensure the entire pipeline failure is detected and causes the
build to fail.
| ARG BUILD_ENV_VARS | ||
|
|
||
| # 전달받은 ARG 환경 변수를 .env.production 파일에 저장 | ||
| RUN echo "$BUILD_ENV_VARS" | tr ' ' '\n' > .env.production |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
공백 분리 방식은 특수문자가 포함된 시크릿에서 깨질 수 있습니다
URL 이나 키에 공백·탭·개행이 들어갈 가능성은 낮지만, &, ?, = 등 셸 메타문자가 포함되면 YAML->Docker 전달 과정에서 예기치 않은 파싱이 일어날 수 있습니다.
안전성을 높이려면:
- YAML 단계에서
|멀티라인 블록을 사용해 이미 개행으로 구분하거나 --build-arg를 변수별로 반복 전달하는 전통적인 방식을 유지
하는 방법을 검토해 주세요.
🧰 Tools
🪛 Hadolint (2.12.0)
[warning] 35-35: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
(DL4006)
🤖 Prompt for AI Agents
In Dockerfile at line 35, the current method of splitting BUILD_ENV_VARS by
spaces can break if secrets contain special shell characters like &, ?, or =. To
fix this, change the approach to either pass the environment variables as a
multiline string using a YAML block scalar (|) so they are already
newline-separated, or switch to passing each build argument individually with
separate --build-arg flags to avoid parsing issues during Docker build.
📌 변경 사항 개요
Docker 이미지 빌드 시점에 환경 변수가 누락되어 발생하던 APi 경로 오류
📝 상세 내용
🔗 관련 이슈
🖼️ 스크린샷(선택사항)
💡 참고 사항
Summary by CodeRabbit
.env.production파일에 저장되도록 변경되었습니다. 이로 인해 배포 환경 설정이 더욱 일관되고 간편해졌습니다.