-
Notifications
You must be signed in to change notification settings - Fork 1
chore: 로컬 도커(api+db) 구성 추가하고 환경변수를 파일 기반으로 분리 #94
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # git-ranker 로컬 도커 실행용 환경변수 템플릿 (SPRING_PROFILES_ACTIVE=local) | ||
| # 사용법: cp .env.local.example .env.local 후 값 채우기 (.env.local 은 gitignore 대상) | ||
| # 실행: docker compose --env-file .env.local -f docker-compose.local.yml up -d --build | ||
|
|
||
| # --- Database (local) --- | ||
| DB_NAME=git_ranker | ||
| DB_USERNAME=root | ||
| DB_PASSWORD=root | ||
|
|
||
| # --- GitHub OAuth App (local): 본인 OAuth App 값 --- | ||
| GITHUB_CLIENT_ID= | ||
| GITHUB_CLIENT_SECRET= | ||
| GITHUB_REDIRECT_URI=http://localhost:8080/login/oauth2/code/github | ||
|
|
||
| # --- JWT: JWT_SECRET 은 32바이트 이상 랜덤 시크릿 --- | ||
| JWT_SECRET= | ||
| JWT_ACCESS_TOKEN_EXPIRATION=900000 | ||
| JWT_REFRESH_TOKEN_EXPIRATION=86400000 | ||
|
|
||
| # --- GitHub GraphQL API tokens (comma-separated, 토큰 풀 로테이션) --- | ||
| GITHUB_API_TOKENS= |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # 로컬 개발용 (SPRING_PROFILES_ACTIVE=local): API + MySQL 두 컨테이너만. | ||
| # 운영 스택(docker-compose.yml)과 분리 — 모니터링(Prometheus/Loki/Grafana) 없음. | ||
| # 실행: docker compose --env-file .env.local -f docker-compose.local.yml up -d --build | ||
| # 검증: curl http://localhost:9090/actuator/health | ||
| services: | ||
| git-ranker-api: | ||
| build: . | ||
| container_name: git-ranker-api-local | ||
| ports: | ||
| - "8080:8080" | ||
| - "127.0.0.1:9090:9090" | ||
| environment: | ||
| SPRING_PROFILES_ACTIVE: local | ||
| # application-local.yml이 ${DB_URL}을 읽음 → 컨테이너에선 localhost가 아니라 DB 서비스명으로 구성 | ||
| DB_URL: jdbc:mysql://git-ranker-db:3306/${DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | ||
| DB_USERNAME: ${DB_USERNAME} | ||
| DB_PASSWORD: ${DB_PASSWORD} | ||
| GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} | ||
| GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET} | ||
| GITHUB_REDIRECT_URI: ${GITHUB_REDIRECT_URI} | ||
| GITHUB_API_TOKENS: ${GITHUB_API_TOKENS} | ||
| JWT_SECRET: ${JWT_SECRET} | ||
| JWT_ACCESS_TOKEN_EXPIRATION: ${JWT_ACCESS_TOKEN_EXPIRATION} | ||
| JWT_REFRESH_TOKEN_EXPIRATION: ${JWT_REFRESH_TOKEN_EXPIRATION} | ||
| TZ: Asia/Seoul | ||
| depends_on: | ||
| git-ranker-db: | ||
| condition: service_healthy | ||
| healthcheck: | ||
| test: ["CMD", "wget", "-q", "--spider", "http://localhost:9090/actuator/health"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 10 | ||
| networks: | ||
| - git-ranker-local-net | ||
|
|
||
| git-ranker-db: | ||
| image: mysql:8.0 | ||
| container_name: git-ranker-db-local | ||
| restart: unless-stopped | ||
| environment: | ||
| MYSQL_DATABASE: ${DB_NAME} | ||
| MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} # 앱이 root로 접속 (DB_USERNAME=root). MySQL 이미지는 MYSQL_USER=root를 거부하므로 root 계정 사용. | ||
| TZ: Asia/Seoul | ||
| ports: | ||
| - "127.0.0.1:3306:3306" | ||
| volumes: | ||
| - mysql_data_local:/var/lib/mysql | ||
| healthcheck: | ||
| test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 10 | ||
| networks: | ||
| - git-ranker-local-net | ||
|
|
||
| networks: | ||
| git-ranker-local-net: | ||
| driver: bridge | ||
|
|
||
| volumes: | ||
| mysql_data_local: | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,22 +4,26 @@ spring: | |||||||||||||||
| on-profile: local | ||||||||||||||||
|
|
||||||||||||||||
| datasource: | ||||||||||||||||
| url: jdbc:mysql://localhost:3306/git_ranker?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul | ||||||||||||||||
| username: ${LOCAL_DB_USERNAME} | ||||||||||||||||
| password: ${LOCAL_DB_PASSWORD} | ||||||||||||||||
| url: ${DB_URL} | ||||||||||||||||
| username: ${DB_USERNAME} | ||||||||||||||||
| password: ${DB_PASSWORD} | ||||||||||||||||
|
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 로컬 실행을 위한 데이터베이스 설정에 기본값을 추가하세요.
호스트에서 실행할 때 🐛 제안하는 수정안 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| driver-class-name: com.mysql.cj.jdbc.Driver | ||||||||||||||||
|
|
||||||||||||||||
| jpa: | ||||||||||||||||
| hibernate: | ||||||||||||||||
| ddl-auto: update | ||||||||||||||||
|
|
||||||||||||||||
| security: | ||||||||||||||||
| oauth2: | ||||||||||||||||
| client: | ||||||||||||||||
| registration: | ||||||||||||||||
| github: | ||||||||||||||||
| client-id: ${LOCAL_GITHUB_CLIENT_ID} | ||||||||||||||||
| client-secret: ${LOCAL_GITHUB_CLIENT_SECRET} | ||||||||||||||||
| client-id: ${GITHUB_CLIENT_ID} | ||||||||||||||||
| client-secret: ${GITHUB_CLIENT_SECRET} | ||||||||||||||||
| scope: | ||||||||||||||||
| - read:user | ||||||||||||||||
| - user:email | ||||||||||||||||
| redirect-uri: ${LOCAL_GITHUB_REDIRECT_URI} | ||||||||||||||||
| redirect-uri: ${GITHUB_REDIRECT_URI} | ||||||||||||||||
|
|
||||||||||||||||
| jwt: | ||||||||||||||||
| secret: ${JWT_SECRET} | ||||||||||||||||
|
|
@@ -39,4 +43,4 @@ app: | |||||||||||||||
| authorized-redirect-uri: http://localhost:3000/auth/callback | ||||||||||||||||
| cookie: | ||||||||||||||||
| domain: localhost | ||||||||||||||||
| secure: false | ||||||||||||||||
| secure: false | ||||||||||||||||
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.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: alexization/git-ranker
Length of output: 313
🏁 Script executed:
Repository: alexization/git-ranker
Length of output: 315
🏁 Script executed:
Repository: 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