Skip to content

[26.04.04 / TASK-268] Chore - 프로덕션용 환경변수 파일 .env.prod 추가#53

Open
ooheunda wants to merge 3 commits intomainfrom
chore/split-env
Open

[26.04.04 / TASK-268] Chore - 프로덕션용 환경변수 파일 .env.prod 추가#53
ooheunda wants to merge 3 commits intomainfrom
chore/split-env

Conversation

@ooheunda
Copy link
Copy Markdown
Member

@ooheunda ooheunda commented Apr 3, 2026

🔥 변경 사항

  • 로컬/운영 환경변수를 분리하였습니다. 값 참고
  • 로컬(.env): 평소처럼 pnpm dev를 통해 실행하면 됨
  • 운영(.env.prod): run.shdocker compose up을 통해 실행시 자동으로 prod 값이 주입됨
  • 로컬에서 운영 환경변수로 실행이 필요할때 dotenv.config({ path: '.env.prod' })를 통해 경로를 설정해주면 되지만, 번거로울 수 있어 그냥 .env 값을 잠시 바꾸는 것을 추천

🏷 관련 이슈

  • X

📸 스크린샷 (UI 변경 시 필수)

X

📌 체크리스트

  • 기능이 정상적으로 동작하는지 테스트 완료
  • 코드 스타일 가이드 준수 여부 확인
  • 관련 문서 업데이트 완료 (필요 시)

Summary by CodeRabbit

릴리스 노트

  • Chores
    • 개발 환경 샘플(.env.sample)의 기본값을 빈값·로컬호스트 중심으로 정리 (외부 URL/고정 키/시크릿 제거).
    • .gitignore에 프로덕션 환경 파일(.env.prod) 추가.
    • 도커 컴포즈 설정이 컨테이너 환경을 .env.prod에서 로드하도록 업데이트.
  • Tests
    • 일부 통합 테스트의 타임아웃을 30초에서 60초로 늘려 안정성 향상.

@ooheunda ooheunda self-assigned this Apr 3, 2026
@ooheunda ooheunda added the enhancement New feature or request label Apr 3, 2026
@notion-workspace
Copy link
Copy Markdown

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cbf1625d-7321-401d-8825-d1c3aeb8ab52

📥 Commits

Reviewing files that changed from the base of the PR and between 3695a5e and bdee311.

📒 Files selected for processing (1)
  • src/repositories/__test__/integration/leaderboard.repo.integration.test.ts
✅ Files skipped from review due to trivial changes (1)
  • src/repositories/test/integration/leaderboard.repo.integration.test.ts

Walkthrough

.env.sample의 민감값들을 기본 빈값으로 정리하고 .env.prod를 .gitignore에 추가했으며, Docker Compose api 서비스가 .env.prod를 로드하도록 변경했습니다. 통합 테스트의 Jest 타임아웃이 30000ms에서 60000ms로 늘어났습니다.

Changes

Cohort / File(s) Summary
환경 샘플 정규화
​.env.sample
민감값 및 환경 기본값들을 빈 문자열로 변경: ALLOWED_ORIGINS 축소(http://localhost,http://localhost:3000), NODE_ENV 인용부호 제거, AES_KEY_0..AES_KEY_9 빈값화, DB/Redis/Slack/Sentry 관련 값들 초기화(DATABASE_NAME=postgres, POSTGRES_USER/POSTGRES_PASSWORD 빈값 등).
프로덕션 환경 파일 무시 설정
.gitignore
.env.prod 패턴 추가로 프로덕션 env 파일을 버전관리에서 제외하도록 변경.
Docker Compose 환경 로드 변경
docker-compose.yml
api 서비스의 env_file을 기존 .env에서 .env.prod로 변경하여 컨테이너가 로드하는 env 파일을 변경.
테스트 타임아웃 증가
src/repositories/__test__/integration/leaderboard.repo.integration.test.ts
Jest per-test timeout을 30,000ms에서 60,000ms로 연장(관련 주석 업데이트 포함).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Nuung
  • Jihyun3478
  • six-standard

Poem

🐰
깡충깡충 깃발 따라 왔네
비밀값은 흙속에 묻고
샘플은 맑은 새옷 걸쳤네
컨테이너는 조용히 환경 읽고
배포 전 당근 한 입 먹지니 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 프로덕션용 환경변수 파일 .env.prod 추가라는 주요 변경사항을 명확하게 요약하고 있으며, 실제 변경사항(.env.prod 추가, .gitignore 업데이트, docker-compose.yml 수정, 통합테스트 타임아웃 연장)과 부합합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/split-env

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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=jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

Based on learnings: The AES keys provided in the .env.sample file 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

📥 Commits

Reviewing files that changed from the base of the PR and between ce7501e and 42b5d0b.

📒 Files selected for processing (3)
  • .env.sample
  • .gitignore
  • docker-compose.yml

- ./logs/api:/usr/src/app/logs
env_file:
- .env
- .env.prod
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Apr 3, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 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 스텝)가 일관되게 동일한 파일명을 사용하도록 업데이트하세요.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

#52 머지후 이어가는게 나을 것 같습니다.

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.

@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`은 개발 및 배포 환경 모두에서 고정된 값으로, 환경 변수로 이동하지 않고 상수로 설정하여 가독성을 높이는 것이 좋습니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

근데 생각해보니까 CI에서 prod값이 필요하지 않습니다. (docker compose로 서버를 실행하지 않고 코드 검사만함) 그냥 냅둬도 될 것 같아요.

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.

@ooheunda, 좋은 설명 감사합니다! CI에서 docker compose로 서버를 실행하지 않고 코드 검사만 수행한다면, docker-compose.ymlenv_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` 파일에서는 데이터베이스 접속 정보를 포함한 환경 변수에 예시 값을 사용하며, 이는 실제 자격 증명이 아니므로 그대로 두어도 됩니다.

Copy link
Copy Markdown
Member

@six-standard six-standard left a comment

Choose a reason for hiding this comment

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

코드 잘 읽었습니다!

단순 env 및 docker-compose 파일 수정이라 문제되는 부분은 없는 것 같고, ssh 키 쪽만 잘 확인해보겠습니다!

Copy link
Copy Markdown
Contributor

@Jihyun3478 Jihyun3478 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!!🙌🔥

노션 아카이빙에 업데이트 해주신 .env.env.sample 모두 현재 제가 작성한 부분과 동일한 것 확인했습니다. 노션 태스크 페이지에 현재 제 env도 참고용으로 올려두었어요!!

노션 태스크 페이지


dotenv.config();
jest.setTimeout(30000); // 각 케이스당 30초 타임아웃 설정
jest.setTimeout(45000); // 각 케이스당 45초 타임아웃 설정
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.

타임아웃을 늘리신 이유가 있을까요? 궁금해서 여쭤보아요🧐

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

api 3번 쓰는 테스트 케이스가 자꾸 타임아웃으로 실패해서 늘려놓았는데, 아직 부족한것같네요...💦
데이터가 늘어서 그런 것 같은데 일단 더 늘려두려고 합니다...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants