Skip to content

fix: port와 db 연결 방식 변경#42

Merged
choubung merged 4 commits intomasterfrom
dev
Nov 17, 2025
Merged

fix: port와 db 연결 방식 변경#42
choubung merged 4 commits intomasterfrom
dev

Conversation

@choubung
Copy link
Copy Markdown
Owner

@choubung choubung commented Nov 17, 2025

Summary by CodeRabbit

  • 새로운 기능

    • Cloud SQL을 통한 내부 터널 기반 데이터베이스 연결 지원 추가로 보안 강화
    • 애플리케이션이 환경 변수(PORT)로 서버 포트를 읽어 기본값(9090)으로 동작 가능
  • 변경 사항

    • 배포 구성과 데이터베이스 연결 방식이 Cloud SQL 소켓 기반으로 업데이트되어 배포 시 해당 설정이 적용됨

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 17, 2025

Warning

Rate limit exceeded

@choubung has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 34 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1a2f799 and cfc30d6.

📒 Files selected for processing (1)
  • build.gradle (1 hunks)

Walkthrough

Cloud Run 배포에 Cloud SQL 내부 터널을 위한 인스턴스 연결을 추가하고, JDBC에 Cloud SQL Socket Factory를 사용하도록 DB_URL을 변경했으며 MySQL Socket Factory 의존성을 추가하고 서버 포트를 PORT 환경변수로 구성 가능하게 바꿨습니다.

Changes

응집도 / 파일(s) 변경 요약
클라우드 런/DB 연결
​.github/workflows/cd.yml
Cloud Run 배포 단계에 add-cloudsql-instances 필드(Cloud SQL 연결 이름) 추가; DB_URL 환경변수를 Cloud SQL 소켓 팩토리(cloudSqlInstance 포함) 사용 형태로 변경.
의존성
build.gradle
implementation 'com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.14.0' 의존성 추가.
런타임 구성
src/main/resources/application.properties
server.port 값을 PORT 환경변수(기본 9090)에서 가져오도록 변경.

Sequence Diagram(s)

sequenceDiagram
    participant App as 애플리케이션
    participant SF as Socket Factory
    participant CT as Cloud SQL 터널
    participant DB as MySQL DB

    Note over App,DB: 이전(직접 연결)
    App->>DB: DB_URL(비소켓)로 직접 접속

    Note over App,DB: 변경된 흐름(소켓 팩토리 + 내부 터널)
    App->>SF: DB_URL + cloudSqlInstance로 접속 요청
    SF->>CT: 내부 터널 생성 요청
    CT->>DB: Cloud SQL 연결
    DB-->>CT: 응답
    CT-->>SF: 터널링된 연결 반환
    SF-->>App: 소켓을 통한 DB 연결 제공
Loading

Estimated code review effort

🎯 2 (단순) | ⏱️ ~10분

  • cd.yml의 add-cloudsql-instances 값(형식: project:region:instance) 및 비밀/권한 설정 확인 필요
  • Socket Factory 버전 호환성(커넥터 vs JDBC 드라이버) 검토 권장
  • PORT 환경변수 기본값과 배포 환경 일치 여부 검증

Possibly related PRs

Suggested labels

👩‍🔧 CI/CD

축하 시

🐰 홉! 터널을 파고 지나,
소켓으로 DB와 악수했네,
포트는 바람결에 맡기고,
배포는 반짝이며 웃네. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 주요 내용을 명확하게 요약하고 있습니다. 포트 설정 변경과 데이터베이스 연결 방식 변경이라는 두 가지 핵심 변경 사항을 직접적으로 언급하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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 (1)
.github/workflows/cd.yml (1)

74-74: 데이터베이스 이름 mydb를 환경 변수로 구성하는 것을 검토하세요.

현재 JDBC URL에 데이터베이스 이름이 하드코딩되어 있습니다. 프로덕션 환경과 개발 환경에서 다른 데이터베이스를 사용해야 한다면, 환경 변수로 분리하는 것이 좋습니다.

-            DB_URL=jdbc:mysql://google/mydb?socketFactory=com.google.cloud.sql.mysql.SocketFactory&cloudSqlInstance=${{ secrets.GCP_SQL_CONNECTION_NAME }}&useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8
+            DB_URL=jdbc:mysql://google/${{ secrets.DB_NAME }}?socketFactory=com.google.cloud.sql.mysql.SocketFactory&cloudSqlInstance=${{ secrets.GCP_SQL_CONNECTION_NAME }}&useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0e2be7 and ebd54f0.

📒 Files selected for processing (3)
  • .github/workflows/cd.yml (1 hunks)
  • build.gradle (1 hunks)
  • src/main/resources/application.properties (1 hunks)
🔇 Additional comments (2)
src/main/resources/application.properties (1)

3-3: 환경 변수 기반 동적 포트 설정이 올바르게 구현되었습니다.

Spring 속성 자리표시자 문법을 올바르게 사용하였고, 기본값 9090으로 이전 환경과의 하위 호환성을 유지합니다. 기존 데이터베이스 설정 패턴과도 일관성이 있습니다.

.github/workflows/cd.yml (1)

67-68: Cloud SQL 내부 터널 설정이 올바르게 구성되었습니다.

add-cloudsql-instances 필드로 Cloud Run과 Cloud SQL 인스턴스 간의 내부 터널을 설정하는 것이 올바릅니다. 이를 통해 공개 IP를 노출하지 않고 안전하게 연결할 수 있습니다.

Copy link
Copy Markdown

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebd54f0 and 1a2f799.

📒 Files selected for processing (1)
  • build.gradle (1 hunks)

@choubung choubung merged commit d6c19cf into master Nov 17, 2025
2 checks passed
@choubung choubung self-assigned this Nov 19, 2025
@choubung choubung added 🚨 bug Something isn't working 👩‍🔧 CI/CD labels Nov 19, 2025
@choubung choubung added this to the 2️⃣ 배포 milestone Nov 19, 2025
@choubung choubung linked an issue Nov 19, 2025 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚨 bug Something isn't working 👩‍🔧 CI/CD

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CI/CD: 배포

1 participant