Skip to content

chore(storage): S3 대신 Pi 디스크 파일 저장소 사용 (S3 구현 유지) - #202

Merged
eclipse021 merged 5 commits into
mainfrom
junhyeon/chore/196-object-storage
Oct 25, 2026
Merged

eclipse021 merged 5 commits into
mainfrom
junhyeon/chore/196-object-storage

Conversation

@eclipse021

@eclipse021 eclipse021 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #196

Summary

서버를 라즈베리파이로 옮기고 AWS를 정리하기 위해 파일 저장소를 S3에서 Pi 디스크로 바꿉니다. 기존 S3 구현은 지우지 않았고, storage.type 설정으로 둘 중 하나를 고릅니다(기본값 filesystem).

Changes

  • 저장소 전환 (storage.type)
    • filesystem(기본): FileSystemFileUploader가 /app/storage/{prefix}/{uuid}.{ext} 위치에 저장합니다. FileSystemPublicUrlResolver는
      {STORAGE_PUBLIC_BASE_URL}/files/{key} 형태의 URL을 만듭니다.
    • s3: 기존 S3Config/S3Uploader/S3PublicUrlResolver를 그대로 씁니다. 각 클래스에는 조건 어노테이션 한 줄만 추가했습니다.
    • 서비스의 @Qualifier("s3PublicUrlResolver")는 바꾸지 않았고, 파일시스템 쪽 resolver도 같은 빈 이름으로 등록됩니다.
  • 아이콘 공개: GET /files/category-icon/**만 정적 리소스로 내려줍니다(30일 캐시). 영수증(receipts/)은 개인정보가 있어 공개하지 않습니다.
  • 보안: 확장자는 영숫자만 허용해 ../ 같은 경로 조작을 막습니다.
  • 404 처리: 없는 경로나 정적 파일 요청이 catch-all 핸들러에서 500으로 바뀌던 문제를 고쳐 404로 응답합니다.
  • 인프라
    • Dockerfile에서 /app/storage를 만들고 소유자를 지정합니다.
    • compose에 orbit-storage-data 볼륨을 추가했습니다.
    • env.example에 STORAGE_TYPE, STORAGE_PUBLIC_BASE_URL을 추가했습니다. S3 변수는 s3 모드에서만 필요합니다.
  • 문서: infra/pi/README.md에 S3 백업을 볼륨으로 복원하는 절차와 icons.url 갱신 SQL을 정리했습니다.

검증

  • ./gradlew harness 통과
  • FileSystemFileUploaderTest: 저장, 경로 조작 차단, URL 생성
  • StorageConfigTest: 아이콘 200·Cache-Control, 없는 아이콘·영수증·경로 조작 404
  • StorageTypeSwitchTest: type이 없으면 파일시스템 빈만, s3면 S3 빈만 등록되는지 확인
  • Pi에서 격리 컨테이너로 스모크 테스트 완료
    • 볼륨 소유자 10001, 백업 복원, 쓰기 확인
    • 아이콘 200, 영수증·경로 조작 차단

Etc

  • 배포 전 확인: Secret ENV_FILE에 STORAGE_PUBLIC_BASE_URL이 있어야 합니다. 없으면 앱이 뜨지 않습니다.
  • 배포 후 작업: Pi의 ~/s3-backup을 볼륨에 복원하고, DB의 icons.url을 갱신합니다(README 참고).
  • #165와 충돌 예정: #165가 FileUploader.download()를 추가하므로, 둘 중 나중에 머지하는 쪽에서 FileSystemFileUploader.download()를 구현해야 합니다.
    GlobalExceptionHandler에서도 충돌이 날 수 있습니다.

Summary by CodeRabbit

  • 새 기능
    • 프로덕션 환경에서 파일을 로컬 저장소에 저장하고, 공개 카테고리 아이콘 경로로 제공하도록 지원합니다. 영수증 파일은 공개 경로로 제공되지 않습니다.
    • 기존 S3 저장소를 설정으로 선택할 수 있습니다.
  • 문서
    • Raspberry Pi 환경의 파일 저장소 설정과 S3 백업 복원 절차를 안내합니다.

eclipse021 and others added 4 commits October 25, 2026 23:16
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- storage.type=filesystem(기본)이면 /app/storage에 저장하고 아이콘만 /files/category-icon/** 로 공개
- storage.type=s3이면 기존 S3 구현을 그대로 사용 (S3 코드는 유지)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eclipse021
eclipse021 requested a review from a team as a code owner October 25, 2026 15:52
@eclipse021
eclipse021 requested review from jminkkk and ziweek October 25, 2026 15:52
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c480d57-ef71-49a0-961d-78fd00639bdc
Commits

Reviewing files that changed from the base of the PR and between 0df9fbf and 97a7fb7.

Files selected for processing: 1
  • src/test/kotlin/depromeet/hotsix/obrit/notification/service/NotificationDispatchServiceTest.kt

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cd4da4b2-1ddb-41d4-b693-945d0eb680ef
Commits

Reviewing files that changed from the base of the PR and between 11aaaf2 and 0df9fbf.

Files selected for processing: 20
  • Dockerfile
  • docker-compose.pi.yml
  • docs/plans/2026-09-30-raspberry-pi-migration-design.md
  • infra/pi/README.md
  • infra/pi/env.example
  • src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/FileSystemFileUploader.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/FileSystemPublicUrlResolver.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/S3PresignedUrlResolver.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/S3PublicUrlResolver.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/S3Uploader.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/StorageProperties.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/config/AdminSecurityConfig.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/config/S3Config.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/config/StorageConfig.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/config/WebMvcConfig.kt
  • src/main/kotlin/depromeet/hotsix/obrit/global/exception/GlobalExceptionHandler.kt
  • src/main/resources/application-prod.yml
  • src/test/kotlin/depromeet/hotsix/obrit/global/common/storage/FileSystemFileUploaderTest.kt
  • src/test/kotlin/depromeet/hotsix/obrit/global/config/StorageConfigTest.kt
  • src/test/kotlin/depromeet/hotsix/obrit/global/config/StorageTypeSwitchTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

프로덕션 기본 파일 저장소를 S3에서 파일시스템으로 전환할 수 있도록 설정과 업로드 기능을 추가했습니다. 아이콘 경로만 공개하며, Raspberry Pi의 Docker 볼륨에 파일을 저장하고 복원하는 운영 절차를 문서화했습니다. S3 저장소는 설정으로 선택할 수 있습니다.

Changes

프로덕션 파일 저장소

Layer / File(s) Summary
저장소 설정과 선택
src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/StorageProperties.kt, src/main/resources/application-prod.yml, src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/*, src/main/kotlin/depromeet/hotsix/obrit/global/config/S3Config.kt, src/test/kotlin/depromeet/hotsix/obrit/global/config/StorageTypeSwitchTest.kt
storage.type 기본값을 filesystem으로 설정하고, 프로덕션에서 파일시스템 또는 S3 구현을 선택하도록 변경했습니다. 저장소 유형별 빈 등록을 테스트합니다.
파일 저장과 아이콘 제공
src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/FileSystemFileUploader.kt, src/main/kotlin/depromeet/hotsix/obrit/global/common/storage/FileSystemPublicUrlResolver.kt, src/main/kotlin/depromeet/hotsix/obrit/global/config/StorageConfig.kt, src/main/kotlin/depromeet/hotsix/obrit/global/config/AdminSecurityConfig.kt, src/main/kotlin/depromeet/hotsix/obrit/global/config/WebMvcConfig.kt, src/main/kotlin/depromeet/hotsix/obrit/global/exception/GlobalExceptionHandler.kt, src/test/kotlin/depromeet/hotsix/obrit/global/common/storage/FileSystemFileUploaderTest.kt, src/test/kotlin/depromeet/hotsix/obrit/global/config/StorageConfigTest.kt
파일을 UUID 이름으로 저장하고 공개 URL을 구성합니다. /files/category-icon/** 경로만 정적 리소스로 제공하며, 업로드와 URL 구성, 캐시 헤더, 비공개 경로 및 404 응답을 테스트합니다.
Pi 영속 저장소와 운영 절차
Dockerfile, docker-compose.pi.yml, infra/pi/env.example, infra/pi/README.md, docs/plans/2026-09-30-raspberry-pi-migration-design.md
/app/storage를 앱 사용자 소유로 생성하고 orbit-storage-data 볼륨에 연결합니다. 파일시스템 및 S3 설정 예시와 백업 복원·접근 확인 절차를 문서에 추가했습니다.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Admin as 백오피스
  participant Uploader as FileSystemFileUploader
  participant Storage as 파일시스템
  participant Resolver as FileSystemPublicUrlResolver
  participant Client as 요청 클라이언트
  participant Static as StorageConfig

  Admin->>Uploader: prefix와 파일로 업로드 요청
  Uploader->>Storage: prefix 아래 파일 저장
  Uploader-->>Admin: 파일 키 반환
  Resolver->>Resolver: 공개 기본 URL과 files 경로에 키 결합
  Client->>Static: /files/category-icon/** 요청
  Static->>Storage: 공개 아이콘 경로의 파일 조회
  Static-->>Client: 파일 응답과 캐시 헤더 반환
Loading
Merge Risk: Minimal · up to 0df9f

The storage switch is ready for normal deployment checks, including configuring the public base URL and completing the documented file restore.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning 직접 연결된 #196은 MySQL·MinIO의 Compose 구성과 데이터 영속화, S3 저장 코드를 MinIO에 맞게 변경하고 이미지 URL을 정리하는 작업을 요구합니다. 이 PR은 파일시스템 저장소와 선택적 기존 S3 저장소를 추가하지만, 변경 요약에 MySQL·MinIO Compose 구성, MinIO 연동 코드, 또는 해당 동작을 검증하는 테스트가 … #196의 코딩 요구에 맞게 MySQL·MinIO Compose 구성과 영속 볼륨을 추가하고, 저장소 구현을 MinIO에 맞게 변경하며 이미지 URL 처리를 완료해야 합니다. 앱만 교체하는 CI/CD 변경도 구현하고 자동화 테스트로 검증해야 합니다. 파일시스템 저장소를 최종 대안으로 사용할 경우 #196의 요구사항과 PR 범위를 먼저 갱신해야 합니다.
Docstring Coverage Warning Docstring coverage is 15.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 14 files. (6 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 제목은 PR의 핵심 변경인 기본 파일 저장소를 S3에서 Pi 디스크로 바꾼 내용과 S3 구현 유지 사항을 잘 나타냅니다. 변경 파일 목록에 있는 storage.type 분기, 아이콘 공개 경로, 404 처리 등 세부 사항은 제목에 없지만 필수 요건은 아닙니다. 제목은 짧은 한 문장이며 모호한 표현이 없습니다.
Out of Scope Changes check Passed 파일시스템 저장소, 아이콘 공개 제한, 환경 변수, Pi 볼륨 설정, S3 백업 복원 문서는 Raspberry Pi 이전과 저장소 운영에 직접 연결됩니다. 변경 요약에서 #196과 무관한 기능이나 독립적인 제품 영역의 변경은 확인되지 않습니다.
Full details: Linked Issues check

Explanation

직접 연결된 #196은 MySQL·MinIO의 Compose 구성과 데이터 영속화, S3 저장 코드를 MinIO에 맞게 변경하고 이미지 URL을 정리하는 작업을 요구합니다. 이 PR은 파일시스템 저장소와 선택적 기존 S3 저장소를 추가하지만, 변경 요약에 MySQL·MinIO Compose 구성, MinIO 연동 코드, 또는 해당 동작을 검증하는 테스트가 없습니다. CI/CD를 앱만 교체하도록 변경한 근거도 없습니다. 저장소 전환 관련 자체 테스트는 있으나 #196의 핵심 코딩 요구를 충족하지 않습니다.

Resolution

#196의 코딩 요구에 맞게 MySQL·MinIO Compose 구성과 영속 볼륨을 추가하고, 저장소 구현을 MinIO에 맞게 변경하며 이미지 URL 처리를 완료해야 합니다. 앱만 교체하는 CI/CD 변경도 구현하고 자동화 테스트로 검증해야 합니다. 파일시스템 저장소를 최종 대안으로 사용할 경우 #196의 요구사항과 PR 범위를 먼저 갱신해야 합니다.

Full details: Docstring Coverage

Explanation

Docstring coverage is 15.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 14 files. (6 skipped: 6 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

나는 토끼, 저장 경로를 살펴봐요
파일은 UUID 이름으로 깡총 저장돼요
아이콘 URL은 키를 따라 이어지고
영수증은 공개 경로 밖에 남아요
Pi의 볼륨에 당근처럼 파일이 쌓여요

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eclipse021
eclipse021 merged commit 62b5bc7 into main Oct 25, 2026
2 checks passed
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.

[CHORE] AWS 서버를 라즈베리파이로 이전

1 participant