chore: 로컬 도커(api+db) 구성 추가하고 환경변수를 파일 기반으로 분리 - #94
Conversation
- docker-compose.local.yml 추가: local 프로파일로 api+db만 기동(모니터링 제외) - application-local.yml에서 LOCAL_ 접두사 제거해 prod와 변수명 통일, ddl-auto update로 로컬 스키마 생성 - 환경 구분을 변수명 접두사 대신 .env.local 파일로 전환하고 .env.local.example 템플릿 추가 - .gitignore에 .env.* 무시 규칙 추가(.env*.example 예외) - DEVELOPMENT.md 로컬 도커 실행법과 환경변수 정정
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough로컬 개발용 환경변수 템플릿과 Docker Compose 구성이 추가되었습니다. Spring local 프로파일은 일반 환경변수를 사용하며, API와 MySQL이 healthcheck·전용 네트워크·볼륨으로 실행됩니다. 개발 문서에는 환경변수와 로컬 실행 절차가 반영되었습니다. Changes로컬 Docker 스택
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Developer
participant DockerCompose as docker-compose.local.yml
participant MySQL as git-ranker-db
participant API as git-ranker-api
Developer->>DockerCompose: --env-file .env.local up -d --build
DockerCompose->>MySQL: MySQL 컨테이너 시작
MySQL-->>DockerCompose: mysqladmin ping healthcheck 통과
DockerCompose->>API: API 컨테이너 시작
API->>MySQL: DB_URL로 데이터베이스 연결
API-->>Developer: /actuator/health 응답
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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: 2
🧹 Nitpick comments (1)
docs/DEVELOPMENT.md (1)
24-29: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value코드 블록에 언어(language)를 명시해 주세요.
마크다운 린터(MD040) 경고를 해결하고 가독성을 높이기 위해 코드 블록에
text나env와 같은 언어를 지정하는 것이 좋습니다.🛠 제안하는 수정안
-``` +```env DB_NAME, DB_USERNAME, DB_PASSWORD GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, GITHUB_REDIRECT_URI JWT_SECRET, JWT_ACCESS_TOKEN_EXPIRATION, JWT_REFRESH_TOKEN_EXPIRATION GITHUB_API_TOKENS # GitHub GraphQL 토큰 (콤마 구분, 토큰 풀 로테이션)</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.In
@docs/DEVELOPMENT.mdaround lines 24 - 29, 문서의 환경변수 목록 코드 블록에 언어 식별자env또는
text를 지정해 Markdown 린터 MD040 경고를 해결하세요.</details> <!-- cr-comment:v1:fd88dcbeed8201916feab524 --> _Source: Linters/SAST tools_ </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.Inline comments:
In@docker-compose.local.yml:
- Around line 49-53: Update the MySQL healthcheck command to authenticate as
root using the configured DB_PASSWORD, while preserving the existing host and
healthcheck timing settings.In
@src/main/resources/application-local.yml:
- Around line 7-9: Update the local database url configuration to provide a
localhost-based default when DB_URL is unset, while preserving the existing
DB_URL value when supplied. Keep the username and password environment-variable
references unchanged.
Nitpick comments:
In@docs/DEVELOPMENT.md:
- Around line 24-29: 문서의 환경변수 목록 코드 블록에 언어 식별자
env또는text를 지정해 Markdown 린터
MD040 경고를 해결하세요.</details> <details> <summary>🪄 Autofix (Beta)</summary> Fix all unresolved CodeRabbit comments on this PR: - [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended) - [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Path: .coderabbit.yml **Review profile**: CHILL **Plan**: Pro **Run ID**: `71e307d0-cce4-44bd-8f7c-afa29003ac90` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 3d9ecc490170e1611c606e85478084f2d929bbc3 and eb7c9bcb331134d5bd258a5fe300a9120ca7978a. </details> <details> <summary>📒 Files selected for processing (5)</summary> * `.env.local.example` * `.gitignore` * `docker-compose.local.yml` * `docs/DEVELOPMENT.md` * `src/main/resources/application-local.yml` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
| healthcheck: | ||
| test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 10 |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if mysqladmin ping without password fails in mysql:8.0
docker run --rm -d --name test-mysql -e MYSQL_ROOT_PASSWORD=root mysql:8.0
sleep 15
docker exec test-mysql mysqladmin ping -h localhost || echo "Ping failed without password"
docker stop test-mysqlRepository: alexization/git-ranker
Length of output: 313
🏁 Script executed:
#!/bin/bash
set -euo pipefail
git ls-files docker-compose.local.yml docker-compose.yml .env* 2>/dev/null || true
echo '--- docker-compose.local.yml (relevant section) ---'
nl -ba docker-compose.local.yml | sed -n '1,140p'
echo '--- search for MYSQL env usage ---'
rg -n "MYSQL_ROOT_PASSWORD|DB_PASSWORD|mysqladmin ping|healthcheck|depends_on" -S .Repository: alexization/git-ranker
Length of output: 315
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- docker-compose.local.yml (lines 1-220) ---'
sed -n '1,220p' docker-compose.local.yml | cat -n
echo '--- docker-compose.yml (lines 1-260) ---'
sed -n '1,260p' docker-compose.yml | cat -n
echo '--- .env.local.example ---'
sed -n '1,220p' .env.local.example | cat -n
echo '--- grep relevant symbols ---'
rg -n "MYSQL_ROOT_PASSWORD|DB_PASSWORD|mysqladmin ping|healthcheck|depends_on|service_healthy" docker-compose.local.yml docker-compose.yml .env.local.example -SRepository: alexization/git-ranker
Length of output: 10834
MySQL 헬스체크에 비밀번호를 전달해야 합니다.
mysqladmin ping -h localhost는 MYSQL_ROOT_PASSWORD로 시작한 MySQL에 인증하지 못해 unhealthy 상태에 머물 수 있고, 그 결과 depends_on: service_healthy를 기다리는 API가 시작되지 않을 수 있습니다.
mysqladmin ping -h localhost -uroot -p${DB_PASSWORD}처럼 같은 비밀번호를 넘기세요.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docker-compose.local.yml` around lines 49 - 53, Update the MySQL healthcheck
command to authenticate as root using the configured DB_PASSWORD, while
preserving the existing host and healthcheck timing settings.
| url: ${DB_URL} | ||
| username: ${DB_USERNAME} | ||
| password: ${DB_PASSWORD} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
로컬 실행을 위한 데이터베이스 설정에 기본값을 추가하세요.
.env.local.example 템플릿에는 DB_URL이 정의되어 있지 않아, DEVELOPMENT.md에 안내된 ./gradlew bootRun 명령어로 직접 실행할 경우 환경변수 미해결로 인해 애플리케이션 시작이 실패합니다.
(Docker Compose 환경에서는 docker-compose.local.yml이 DB_URL을 주입하므로 동작하지만, 호스트 기기에서의 직접 실행은 실패합니다.)
호스트에서 실행할 때 localhost를 바라보도록 기본값을 제공하는 것을 권장합니다.
🐛 제안하는 수정안
datasource:
- url: ${DB_URL}
- username: ${DB_USERNAME}
- password: ${DB_PASSWORD}
+ url: ${DB_URL:jdbc:mysql://localhost:3306/${DB_NAME:git_ranker}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul}
+ username: ${DB_USERNAME:root}
+ password: ${DB_PASSWORD:root}📝 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.
| url: ${DB_URL} | |
| username: ${DB_USERNAME} | |
| password: ${DB_PASSWORD} | |
| datasource: | |
| url: ${DB_URL:jdbc:mysql://localhost:3306/${DB_NAME:git_ranker}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul} | |
| username: ${DB_USERNAME:root} | |
| password: ${DB_PASSWORD:root} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/main/resources/application-local.yml` around lines 7 - 9, Update the
local database url configuration to provide a localhost-based default when
DB_URL is unset, while preserving the existing DB_URL value when supplied. Keep
the username and password environment-variable references unchanged.
- 환경변수 목록 코드블록에 text 언어 지정(MD040 해결) - 호스트 bootRun은 spring-dotenv가 읽는 .env(로컬 변수 전체)가 필요함을 주석으로 명시
요약
local프로파일)을 추가하고, 환경 구분을 변수명 접두사(LOCAL_*)에서 환경별.env파일(.env.local)로 전환연관 이슈
검증
./gradlew test— 통과 (도커 temurin 21, CI와 동일 이미지; 호스트 JDK 미설치로 컨테이너에서 실행)./gradlew build -x test— 통과 (상동)docker compose --env-file .env.local -f docker-compose.local.yml up -d --build→ 이미지 빌드·api+db 기동 성공/actuator/health→{"status":"UP", db: UP(MySQL)}(빈 DB에ddl-auto=update로 스키마 자동 생성 확인):8080swagger-ui 200,/api/v1/401 (보안 정상 작동)리뷰어 포커스
docker-compose.local.yml:DB_URL을 컨테이너 호스트(git-ranker-db)로 구성,--env-file .env.local로 값 주입, 이름·볼륨·네트워크에-local접미사로 운영 스택과 격리application-local.yml:LOCAL_접두사 제거해 prod와 변수명 통일,ddl-auto: update추가(base는validate유지 → prod 영향 없음).gitignore:.env.*무시 +!.env*.example예외 (시크릿 커밋 방지)리스크 / 롤백
docker-compose.yml·배포 경로 불변. 로컬 개발 전용 변경Summary by CodeRabbit
새로운 기능
개선 사항
문서