Repository navigation
feat: AI 인사이트 및 S3 이미지 업로드 인프라 설정 개선 - #136
Conversation
- VertexAI 빈에 ConditionalOnProperty 추가 - AiInsightService에서 Optional<VertexAI>로 null-safe 처리
- S3Config에 ConditionalOnExpression 적용 - ImageController의 ConditionalOnBean을 S3Client로 변경
- locked 상태에서도 insight 데이터 반환하도록 수정 - 테스트 코드 findAllById로 수정
- release.yml에 환경변수 추가 - deploy.sh에 선택적 Docker 옵션 구성
- application-local.yml에 Firebase, Gemini, S3 설정 추가 - application-test.yml에 테스트용 더미 설정 추가
Walkthrough외부 서비스(Firebase, Gemini, S3) 통합을 위해 배포 구조를 정비하고, 조건부 빈 등록을 도입하며, Optional 타입을 적용하고, 투표 API 응답을 개선했습니다. Changes외부 서비스 조건부 등록 및 배포 개선
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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
🤖 Prompt for all review comments with 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.
Inline comments:
In @.github/workflows/release.yml:
- Around line 133-135: Do not create an empty Firebase service account file and
restrict its permissions: check that the environment variable
FIREBASE_SERVICE_ACCOUNT_JSON is non-empty before running mkdir/echo to write
/home/ubuntu/app/secrets/firebase-service-account.json (skip creation if empty),
and after writing the file set restrictive permissions (e.g., chmod 600 or chown
to the deploy user) and then export FIREBASE_SERVICE_ACCOUNT_PATH; reference the
variables/paths FIREBASE_SERVICE_ACCOUNT_JSON, FIREBASE_SERVICE_ACCOUNT_PATH and
the target file /home/ubuntu/app/secrets/firebase-service-account.json when
making the change.
In `@src/main/resources/application-local.yml`:
- Around line 61-72: The local config currently enables external integrations by
default; change gemini.enabled to false (and remove or blank gemini.project-id)
and clear or set aws.s3.* values (aws.s3.bucket, aws.s3.region,
aws.s3.access-key, aws.s3.secret-key) to empty/default placeholders so local
profile does not require external services; ensure these values are only enabled
via environment variables or explicit overrides rather than hardcoded defaults.
🪄 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: 2ada9264-d86a-480e-b5c3-a62ba3cec8d1
📒 Files selected for processing (13)
.github/workflows/release.ymlscripts/deploy.shsrc/main/java/com/ject/vs/ai/config/GeminiConfig.javasrc/main/java/com/ject/vs/ai/port/AiInsightService.javasrc/main/java/com/ject/vs/config/S3Config.javasrc/main/java/com/ject/vs/image/adapter/web/ImageController.javasrc/main/java/com/ject/vs/vote/adapter/web/GuestFreeVoteController.javasrc/main/java/com/ject/vs/vote/adapter/web/dto/FreeVotesResponse.javasrc/main/java/com/ject/vs/vote/adapter/web/dto/VoteResultResponse.javasrc/main/resources/application-local.ymlsrc/test/java/com/ject/vs/vote/adapter/web/VoteResultControllerTest.javasrc/test/java/com/ject/vs/vote/port/VoteResultQueryServiceTest.javasrc/test/resources/application-test.yml
| mkdir -p /home/ubuntu/app/secrets | ||
| echo "$FIREBASE_SERVICE_ACCOUNT_JSON" > /home/ubuntu/app/secrets/firebase-service-account.json | ||
| export FIREBASE_SERVICE_ACCOUNT_PATH=/app/secrets/firebase-service-account.json |
There was a problem hiding this comment.
Firebase 시크릿 파일은 비어있는 값일 때 생성하지 말고 권한을 제한해주세요.
Line 133-135은 FIREBASE_SERVICE_ACCOUNT_JSON이 비어도 파일을 생성해 optional 동작을 깨뜨립니다(빈 JSON 파일 마운트). 또한 서비스 계정 파일 권한 제한이 없어 민감정보 노출 위험이 있습니다.
🔧 제안 수정안
- mkdir -p /home/ubuntu/app/secrets
- echo "$FIREBASE_SERVICE_ACCOUNT_JSON" > /home/ubuntu/app/secrets/firebase-service-account.json
- export FIREBASE_SERVICE_ACCOUNT_PATH=/app/secrets/firebase-service-account.json
+ install -d -m 700 /home/ubuntu/app/secrets
+ if [ -n "${FIREBASE_SERVICE_ACCOUNT_JSON:-}" ]; then
+ printf '%s' "$FIREBASE_SERVICE_ACCOUNT_JSON" > /home/ubuntu/app/secrets/firebase-service-account.json
+ chmod 600 /home/ubuntu/app/secrets/firebase-service-account.json
+ export FIREBASE_SERVICE_ACCOUNT_PATH=/app/secrets/firebase-service-account.json
+ else
+ rm -f /home/ubuntu/app/secrets/firebase-service-account.json
+ unset FIREBASE_SERVICE_ACCOUNT_PATH
+ fi📝 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.
| mkdir -p /home/ubuntu/app/secrets | |
| echo "$FIREBASE_SERVICE_ACCOUNT_JSON" > /home/ubuntu/app/secrets/firebase-service-account.json | |
| export FIREBASE_SERVICE_ACCOUNT_PATH=/app/secrets/firebase-service-account.json | |
| install -d -m 700 /home/ubuntu/app/secrets | |
| if [ -n "${FIREBASE_SERVICE_ACCOUNT_JSON:-}" ]; then | |
| printf '%s' "$FIREBASE_SERVICE_ACCOUNT_JSON" > /home/ubuntu/app/secrets/firebase-service-account.json | |
| chmod 600 /home/ubuntu/app/secrets/firebase-service-account.json | |
| export FIREBASE_SERVICE_ACCOUNT_PATH=/app/secrets/firebase-service-account.json | |
| else | |
| rm -f /home/ubuntu/app/secrets/firebase-service-account.json | |
| unset FIREBASE_SERVICE_ACCOUNT_PATH | |
| fi |
🤖 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 @.github/workflows/release.yml around lines 133 - 135, Do not create an empty
Firebase service account file and restrict its permissions: check that the
environment variable FIREBASE_SERVICE_ACCOUNT_JSON is non-empty before running
mkdir/echo to write /home/ubuntu/app/secrets/firebase-service-account.json (skip
creation if empty), and after writing the file set restrictive permissions
(e.g., chmod 600 or chown to the deploy user) and then export
FIREBASE_SERVICE_ACCOUNT_PATH; reference the variables/paths
FIREBASE_SERVICE_ACCOUNT_JSON, FIREBASE_SERVICE_ACCOUNT_PATH and the target file
/home/ubuntu/app/secrets/firebase-service-account.json when making the change.
| # Gemini AI 인사이트 | ||
| gemini: | ||
| project-id: jectvsserver | ||
| enabled: true | ||
|
|
||
| # AWS S3 이미지 업로드 | ||
| aws: | ||
| s3: | ||
| bucket: ject-vs-images | ||
| region: ap-southeast-2 | ||
| access-key: ${AWS_S3_ACCESS_KEY} | ||
| secret-key: ${AWS_S3_SECRET_KEY} |
There was a problem hiding this comment.
local 프로필에서 외부 연동을 기본 활성화하면 “의존성 없이 실행” 목표와 충돌합니다.
Line 61-64(gemini.enabled: true)와 Line 67-72(고정 bucket)는 로컬 기본 실행 시 외부 연동을 사실상 강제합니다. 기본값은 비활성/빈 값으로 두고, 필요 시 환경변수로만 켜는 쪽이 안전합니다.
🔧 제안 수정안
gemini:
- project-id: jectvsserver
- enabled: true
+ enabled: ${GEMINI_ENABLED:false}
+ project-id: ${GEMINI_PROJECT_ID:}
aws:
s3:
- bucket: ject-vs-images
- region: ap-southeast-2
- access-key: ${AWS_S3_ACCESS_KEY}
- secret-key: ${AWS_S3_SECRET_KEY}
+ bucket: ${AWS_S3_BUCKET:}
+ region: ${AWS_S3_REGION:ap-southeast-2}
+ access-key: ${AWS_S3_ACCESS_KEY:}
+ secret-key: ${AWS_S3_SECRET_KEY:}🤖 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 61 - 72, The local
config currently enables external integrations by default; change gemini.enabled
to false (and remove or blank gemini.project-id) and clear or set aws.s3.*
values (aws.s3.bucket, aws.s3.region, aws.s3.access-key, aws.s3.secret-key) to
empty/default placeholders so local profile does not require external services;
ensure these values are only enabled via environment variables or explicit
overrides rather than hardcoded defaults.
📌 관련 이슈
🔍 작업 내용
AI 인사이트 자동 생성(Gemini) 및 S3 이미지 업로드 기능을 추가하고, 외부 서비스 의존성 없이도 로컬/테스트 환경에서 애플리케이션이 정상 실행되도록 조건부 빈 설정을 개선했습니다.
📝 변경 사항
💬 리뷰어에게
Summary by CodeRabbit
릴리스 노트
New Features
Bug Fixes
Chores