[26.04.04 / TASK-268] Chore - 프로덕션용 환경변수 파일 .env.prod 추가#53
[26.04.04 / TASK-268] Chore - 프로덕션용 환경변수 파일 .env.prod 추가#53
.env.prod 추가#53Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
Walkthrough
Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.env.sample (2)
6-15:AES_KEY_*를 빈 값으로 두면 샘플 기반 초기 실행이 즉시 실패합니다.
src/utils/key.util.ts에서 키 길이 32를 강제하므로,.env.sample은 빈 값 대신 32자 더미값을 유지하는 편이 안전합니다(보안 노출 없음).예시 수정안
-AES_KEY_0= -AES_KEY_1= -AES_KEY_2= -AES_KEY_3= -AES_KEY_4= -AES_KEY_5= -AES_KEY_6= -AES_KEY_7= -AES_KEY_8= -AES_KEY_9= +AES_KEY_0=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +AES_KEY_1=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +AES_KEY_2=cccccccccccccccccccccccccccccccc +AES_KEY_3=dddddddddddddddddddddddddddddddd +AES_KEY_4=eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee +AES_KEY_5=ffffffffffffffffffffffffffffffff +AES_KEY_6=gggggggggggggggggggggggggggggggg +AES_KEY_7=hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh +AES_KEY_8=iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii +AES_KEY_9=jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjBased on learnings: The AES keys provided in the
.env.samplefile are sample values and not actual encryption keys.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env.sample around lines 6 - 15, The .env.sample currently leaves AES_KEY_0..AES_KEY_9 empty which causes immediate failures because src/utils/key.util.ts enforces a 32-byte key length; update .env.sample to populate each AES_KEY_* with a 32-character dummy string (safe sample values, e.g. repeated characters or clearly-marked test keys) so the sample runs without breaking while keeping real secrets out of the repo.
18-20: DB 샘플 값까지 비워두면.env.sample의 부트스트랩 역할이 약해집니다.최소한 로컬 기본값(
postgres/postgres등)은 남겨두는 편이 초기 실행 실패를 줄입니다.Based on learnings:
velog-dashboard-v2-api프로젝트의.env.sample파일에서는 데이터베이스 접속 정보를 포함한 환경 변수에 예시 값을 사용하며, 이는 실제 자격 증명이 아니므로 그대로 두어도 됩니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env.sample around lines 18 - 20, The .env.sample currently leaves DATABASE_NAME, POSTGRES_USER, and POSTGRES_PASSWORD empty which reduces its bootstrap usefulness; update the .env.sample to provide safe local example defaults (e.g., a common local DB name and user/password like postgres/postgres) for DATABASE_NAME, POSTGRES_USER, and POSTGRES_PASSWORD so new devs can run locally without immediate configuration changes, while ensuring these are explicitly documented as non-production credentials.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docker-compose.yml`:
- Line 18: docker-compose.yml의 env_file이 `.env.prod`로 설정되어 있어 CI/CD의 "Create
.env file" 단계(api-ci-cd.yaml)에서 생성하는 `.env`와 불일치해 배포 시 환경변수가 누락됩니다; 해결하려면
docker-compose.yml의 env_file 값을 `.env`로 변경하거나 CI/CD 워크플로우의 "Create .env file"
스텝을 수정해 `.env.prod`를 생성하도록 조치하고, 변경한 쪽과 다른 모든 참조(예: 로컬 개발/배포 문서나 다른 workflow
스텝)가 일관되게 동일한 파일명을 사용하도록 업데이트하세요.
---
Nitpick comments:
In @.env.sample:
- Around line 6-15: The .env.sample currently leaves AES_KEY_0..AES_KEY_9 empty
which causes immediate failures because src/utils/key.util.ts enforces a 32-byte
key length; update .env.sample to populate each AES_KEY_* with a 32-character
dummy string (safe sample values, e.g. repeated characters or clearly-marked
test keys) so the sample runs without breaking while keeping real secrets out of
the repo.
- Around line 18-20: The .env.sample currently leaves DATABASE_NAME,
POSTGRES_USER, and POSTGRES_PASSWORD empty which reduces its bootstrap
usefulness; update the .env.sample to provide safe local example defaults (e.g.,
a common local DB name and user/password like postgres/postgres) for
DATABASE_NAME, POSTGRES_USER, and POSTGRES_PASSWORD so new devs can run locally
without immediate configuration changes, while ensuring these are explicitly
documented as non-production credentials.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ce317ad2-b7b6-4e66-b77b-4b6c12708343
📒 Files selected for processing (3)
.env.sample.gitignoredocker-compose.yml
| - ./logs/api:/usr/src/app/logs | ||
| env_file: | ||
| - .env | ||
| - .env.prod |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 목적: compose env_file와 CI에서 생성하는 env 파일명의 불일치 확인 (읽기 전용)
set -euo pipefail
echo "[1] docker-compose env_file 확인"
rg -n -C2 'env_file|\.env|\.env\.prod' docker-compose.yml
echo
echo "[2] GitHub Actions에서 생성하는 env 파일 확인"
fd -i 'api-ci-cd\.ya?ml$' .github/workflows --exec rg -n -C2 'Create \.env file|>> \.env|>> \.env\.prod'
echo
echo "[3] run.sh에서 참조하는 env 파일 확인(존재 시)"
fd -i '^run\.sh$' . --exec rg -n -C2 '\.env|\.env\.prod'Repository: Check-Data-Out/velog-dashboard-v2-api
Length of output: 1799
env_file 파일명이 CI/CD와 불일치하여 배포 시 환경변수 로드 실패를 야기합니다.
docker-compose.yml은 .env.prod를 요구하지만, .github/workflows/api-ci-cd.yaml의 "Create .env file" 단계(라인 53-73)는 .env 파일만 생성합니다. 이 불일치로 컨테이너가 필수 환경변수 없이 올라올 수 있습니다.
다음 중 하나를 수행하세요:
- CI/CD 워크플로우를 수정하여
.env.prod파일을 생성하거나 - docker-compose.yml의
env_file을.env로 변경하세요
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docker-compose.yml` at line 18, docker-compose.yml의 env_file이 `.env.prod`로
설정되어 있어 CI/CD의 "Create .env file" 단계(api-ci-cd.yaml)에서 생성하는 `.env`와 불일치해 배포 시
환경변수가 누락됩니다; 해결하려면 docker-compose.yml의 env_file 값을 `.env`로 변경하거나 CI/CD 워크플로우의
"Create .env file" 스텝을 수정해 `.env.prod`를 생성하도록 조치하고, 변경한 쪽과 다른 모든 참조(예: 로컬 개발/배포
문서나 다른 workflow 스텝)가 일관되게 동일한 파일명을 사용하도록 업데이트하세요.
There was a problem hiding this comment.
@ooheunda, 이해했습니다! PR #52가 먼저 머지된 후 CI/CD 워크플로우에서 .env.prod를 생성하도록 수정되면 이 불일치가 자연스럽게 해소될 것 같습니다. #52 머지 이후에 해당 부분을 다시 확인해 주세요. 👍
🧠 Learnings used
Learnt from: HA0N1
Repo: Check-Data-Out/velog-dashboard-v2-api PR: 4
File: src/middlewares/auth.middleware.ts:48-49
Timestamp: 2024-11-29T14:21:32.376Z
Learning: `auth.middleware.ts` 파일에서 `VELOG_API_URL`은 개발 및 배포 환경 모두에서 고정된 값으로, 환경 변수로 이동하지 않고 상수로 설정하여 가독성을 높이는 것이 좋습니다.
There was a problem hiding this comment.
근데 생각해보니까 CI에서 prod값이 필요하지 않습니다. (docker compose로 서버를 실행하지 않고 코드 검사만함) 그냥 냅둬도 될 것 같아요.
There was a problem hiding this comment.
@ooheunda, 좋은 설명 감사합니다! CI에서 docker compose로 서버를 실행하지 않고 코드 검사만 수행한다면, docker-compose.yml의 env_file 설정은 CI와 무관하므로 지적한 불일치 문제는 실제로 해당되지 않습니다. 현재 상태로 유지하셔도 됩니다. 🐇
( ˶ᵔ ᵕ ᵔ˶ )
✏️ Learnings added
Learnt from: ooheunda
Repo: Check-Data-Out/velog-dashboard-v2-api PR: 53
File: docker-compose.yml:18-18
Timestamp: 2026-04-04T08:50:18.297Z
Learning: `Check-Data-Out/velog-dashboard-v2-api` 프로젝트의 CI/CD 워크플로우(`.github/workflows/api-ci-cd.yaml`)에서는 `docker compose`로 서버를 실행하지 않고 코드 검사(lint/test 등)만 수행합니다. 따라서 CI에서 `.env` 파일을 생성하더라도 `docker-compose.yml`의 `env_file` 설정(`.env.prod`)과 불일치해도 배포에 영향이 없습니다. `docker compose`는 실제 프로덕션 배포 시에만 사용됩니다.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🧠 Learnings used
Learnt from: HA0N1
Repo: Check-Data-Out/velog-dashboard-v2-api PR: 4
File: src/middlewares/auth.middleware.ts:48-49
Timestamp: 2024-11-29T14:21:32.376Z
Learning: `auth.middleware.ts` 파일에서 `VELOG_API_URL`은 개발 및 배포 환경 모두에서 고정된 값으로, 환경 변수로 이동하지 않고 상수로 설정하여 가독성을 높이는 것이 좋습니다.
Learnt from: HA0N1
Repo: Check-Data-Out/velog-dashboard-v2-api PR: 4
File: .env.sample:2-6
Timestamp: 2024-11-29T14:01:26.914Z
Learning: `velog-dashboard-v2-api` 프로젝트의 `.env.sample` 파일에서는 데이터베이스 접속 정보를 포함한 환경 변수에 예시 값을 사용하며, 이는 실제 자격 증명이 아니므로 그대로 두어도 됩니다.
six-standard
left a comment
There was a problem hiding this comment.
코드 잘 읽었습니다!
단순 env 및 docker-compose 파일 수정이라 문제되는 부분은 없는 것 같고, ssh 키 쪽만 잘 확인해보겠습니다!
Jihyun3478
left a comment
There was a problem hiding this comment.
고생하셨습니다!!🙌🔥
노션 아카이빙에 업데이트 해주신 .env와 .env.sample 모두 현재 제가 작성한 부분과 동일한 것 확인했습니다. 노션 태스크 페이지에 현재 제 env도 참고용으로 올려두었어요!!
|
|
||
| dotenv.config(); | ||
| jest.setTimeout(30000); // 각 케이스당 30초 타임아웃 설정 | ||
| jest.setTimeout(45000); // 각 케이스당 45초 타임아웃 설정 |
There was a problem hiding this comment.
타임아웃을 늘리신 이유가 있을까요? 궁금해서 여쭤보아요🧐
There was a problem hiding this comment.
api 3번 쓰는 테스트 케이스가 자꾸 타임아웃으로 실패해서 늘려놓았는데, 아직 부족한것같네요...💦
데이터가 늘어서 그런 것 같은데 일단 더 늘려두려고 합니다...
🔥 변경 사항
.env): 평소처럼pnpm dev를 통해 실행하면 됨.env.prod):run.sh나docker compose up을 통해 실행시 자동으로 prod 값이 주입됨dotenv.config({ path: '.env.prod' })를 통해 경로를 설정해주면 되지만, 번거로울 수 있어 그냥.env값을 잠시 바꾸는 것을 추천🏷 관련 이슈
📸 스크린샷 (UI 변경 시 필수)
X
📌 체크리스트
Summary by CodeRabbit
릴리스 노트
.gitignore에 프로덕션 환경 파일(.env.prod) 추가..env.prod에서 로드하도록 업데이트.