Skip to content

chore: 로컬 도커(api+db) 구성 추가하고 환경변수를 파일 기반으로 분리 - #94

Merged
alexization merged 2 commits into
developfrom
chore/local-docker-compose
Jul 21, 2026
Merged

chore: 로컬 도커(api+db) 구성 추가하고 환경변수를 파일 기반으로 분리#94
alexization merged 2 commits into
developfrom
chore/local-docker-compose

Conversation

@alexization

@alexization alexization commented Jul 21, 2026

Copy link
Copy Markdown
Owner

요약

  • 로컬 개발용 도커 구성(api + db만, local 프로파일)을 추가하고, 환경 구분을 변수명 접두사(LOCAL_*)에서 환경별 .env 파일(.env.local)로 전환

연관 이슈

  • 없음 (ad-hoc 로컬 개발 환경 정비)

검증

  • ./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로 스키마 자동 생성 확인)
    • :8080 swagger-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 예외 (시크릿 커밋 방지)

리스크 / 롤백

  • 낮음. prod 프로파일·기존 docker-compose.yml·배포 경로 불변. 로컬 개발 전용 변경

Summary by CodeRabbit

  • 새로운 기능

    • 로컬 개발 환경에서 API와 MySQL만 간편하게 실행할 수 있는 Docker 구성을 추가했습니다.
    • 데이터베이스, GitHub OAuth, JWT 설정을 위한 환경 변수 템플릿을 제공합니다.
  • 개선 사항

    • 로컬 환경 설정이 표준 환경 변수 체계로 통일되었습니다.
    • 데이터베이스와 API 상태 확인을 통해 안정적인 순서로 실행됩니다.
  • 문서

    • 로컬 Docker 실행 방법과 환경 변수 설정 안내를 업데이트했습니다.

- 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 로컬 도커 실행법과 환경변수 정정
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 8aed52cd-cd3d-4891-b40c-8eb9e4895185

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

로컬 개발용 환경변수 템플릿과 Docker Compose 구성이 추가되었습니다. Spring local 프로파일은 일반 환경변수를 사용하며, API와 MySQL이 healthcheck·전용 네트워크·볼륨으로 실행됩니다. 개발 문서에는 환경변수와 로컬 실행 절차가 반영되었습니다.

Changes

로컬 Docker 스택

Layer / File(s) Summary
로컬 환경변수 계약
.env.local.example, .gitignore, src/main/resources/application-local.yml, docs/DEVELOPMENT.md
로컬 DB·GitHub·JWT 환경변수 템플릿과 예외 규칙이 추가되고, Spring local 프로파일이 일반 환경변수명을 참조하도록 변경되었습니다.
로컬 Compose 실행
docker-compose.local.yml, docs/DEVELOPMENT.md
API와 MySQL 전용 로컬 스택, healthcheck, 네트워크·볼륨 및 실행·종료 명령이 정의되었습니다.

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 응답
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 로컬 Docker(api+db) 추가와 환경변수 파일 분리라는 핵심 변경을 명확히 요약합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/local-docker-compose

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
docs/DEVELOPMENT.md (1)

24-29: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

코드 블록에 언어(language)를 명시해 주세요.

마크다운 린터(MD040) 경고를 해결하고 가독성을 높이기 위해 코드 블록에 textenv와 같은 언어를 지정하는 것이 좋습니다.

🛠 제안하는 수정안
-```
+```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.md around 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 -->

Comment thread docker-compose.local.yml
Comment on lines +49 to +53
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 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-mysql

Repository: 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 -S

Repository: alexization/git-ranker

Length of output: 10834


MySQL 헬스체크에 비밀번호를 전달해야 합니다.
mysqladmin ping -h localhostMYSQL_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.

Comment on lines +7 to +9
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

로컬 실행을 위한 데이터베이스 설정에 기본값을 추가하세요.

.env.local.example 템플릿에는 DB_URL이 정의되어 있지 않아, DEVELOPMENT.md에 안내된 ./gradlew bootRun 명령어로 직접 실행할 경우 환경변수 미해결로 인해 애플리케이션 시작이 실패합니다.
(Docker Compose 환경에서는 docker-compose.local.ymlDB_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.

Suggested change
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(로컬 변수 전체)가 필요함을 주석으로 명시
@alexization
alexization merged commit 371cb45 into develop Jul 21, 2026
2 checks passed
@alexization
alexization deleted the chore/local-docker-compose branch July 21, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant