Skip to content

[CHORE] 로컬 / 개발 환경 분리#33

Merged
dldusgh318 merged 3 commits into
SeCause:developfrom
dldusgh318:develop
Jun 10, 2026
Merged

[CHORE] 로컬 / 개발 환경 분리#33
dldusgh318 merged 3 commits into
SeCause:developfrom
dldusgh318:develop

Conversation

@dldusgh318

@dldusgh318 dldusgh318 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

‼️ 관련 이슈

close #29


🔎 개요

로컬 환경과 개발 서버 환경을 분리하고, 배포 시 Docker 컨테이너가 서버의 환경변수 파일을 읽도록 CD 설정을 개선했습니다.


📝 작업 내용

  • Spring profile 기본값을 local로 설정했습니다.
  • application-local.yml, application-dev.yml 기준으로 로컬/개발 서버 설정을 분리했습니다.
  • 개발 서버의 DB, GitHub OAuth, JWT 관련 값은 환경변수로 주입되도록 변경했습니다.
  • CI/CD에서 secrets.APPLICATION으로 설정 파일을 생성하던 방식을 제거했습니다.
  • CD 배포 단계에서 docker-compose.yml을 생성하고 /etc/secause/secause.envenv_file로 읽도록 수정했습니다.

👀 변경 사항

환경 변수 설정을 주입하는 식으로 수정했으니, 변경사항에 맞게 로컬 설정 부탁드립니다


📸 스크린샷 (Optional)


✅ 체크리스트

  • label, milestone, assignees, reviewers 등을 지정했습니다.
  • 성능 개선/최적화 관련 내용이 있는지 확인했습니다.
  • 변경 사항에 대한 테스트를 했습니다.
  • 테스트 시 사용한 로그를 삭제했습니다.

💬 고민사항 및 리뷰 요구사항 (Optional)

고민사항 및 의견 받고 싶은 부분 있으면 적어두기

Summary by CodeRabbit

  • 신규 기능

    • Swagger API 문서에서 운영(HTTPS)과 로컬(HTTP) 서버 엔드포인트를 선택할 수 있습니다.
  • 기타

    • 개발·로컬 환경용 설정 파일이 추가되어 환경별 구성과 인증·토큰 설정이 정리되었습니다.
    • CI/CD 워크플로우가 간소화되고 배포 스크립트가 업데이트되어 배포 과정이 개선되었습니다.
    • 이제 기본 설정 파일(application.yml)이 저장소에서 추적됩니다.

@dldusgh318 dldusgh318 self-assigned this Jun 9, 2026
@dldusgh318 dldusgh318 added the ⚙️ CHORE 기타 변경사항 (빌드 스크립트 수정, 패키지 매니징 설정 등) label Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d88edac5-b26e-4be9-b22c-5c781dbc65bd

📥 Commits

Reviewing files that changed from the base of the PR and between b76918b and 99f41b6.

📒 Files selected for processing (1)
  • src/main/resources/application-local.yml

📝 Walkthrough

Walkthrough

이 PR은 Spring 프로필을 로컬/개발으로 분리해 설정 YAML을 리포지토리에 추가하고, Swagger에 다중 서버를 등록하며, CI에서 런타임으로 생성하던 application.yml 단계를 제거하고 CD 배포 스크립트가 원격에 docker-compose.yml을 생성하도록 변경합니다.

Changes

환경 프로필 분리 및 Swagger 다중 서버 설정

Layer / File(s) Summary
Spring 프로필 설정 파일
src/main/resources/application.yml, src/main/resources/application-local.yml, src/main/resources/application-dev.yml
application.yml은 기본 활성 프로필을 local로 지정합니다. application-local.yml은 로컬 개발 환경(데이터베이스, SQL 초기화, JPA update, Swagger, OAuth, JWT)을 환경 변수 기반으로 구성합니다. application-dev.yml은 개발 환경(데이터베이스, SQL 초기화, JPA validate, Swagger prod-server, OAuth, JWT)을 환경 변수 기반으로 구성합니다.
설정 파일 버전 관리
.gitignore
src/main/resources/application.yml 항목을 제거하여 설정 파일을 리포지토리에서 추적합니다.
Swagger 다중 서버 설정
src/main/java/SeCause/SeCause_be/global/config/SwaggerConfig.java
springdoc.swagger-ui.prod-server 값을 주입받고, OpenAPI 생성 시 주입된 프로덕션 서버(HTTPS)와 로컬 테스트 서버(http://localhost:8080, HTTP)를 addServersItem으로 추가합니다.

CI/CD 워크플로우 업데이트

Layer / File(s) Summary
CI 워크플로우 조정
.github/workflows/ci.yml
Set up application.yml 단계(시크릿으로 파일 생성)를 제거하여 Gradle 빌드가 커밋된 프로필 기반 설정과 함께 실행됩니다.
CD 배포 스크립트 개선
.github/workflows/cd.yml
SSH 배포 스크립트가 원격에 docker-compose.yml을 heredoc으로 생성(이미지 ${DOCKER_REPO}:latest, env 파일 /etc/secause/secause.env, 포트 8080:8080, restart: unless-stopped)한 뒤 기존 docker compose down, pull, up, image prune 명령을 실행합니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • SeCause/SeCause-BE#2: 두 PR 모두 SwaggerConfig의 OpenAPI/서버 설정을 수정합니다.
  • SeCause/SeCause-BE#4: CD 워크플로우의 application.yml 생성 및 Docker Compose 배포 흐름 변경과 밀접하게 연관됩니다.
  • SeCause/SeCause-BE#10: 새로 추가된 application-*.ymlgithub.oauth.*jwt.* 설정이 해당 PR의 설정 프로퍼티와 연관됩니다.

Poem

🐰 새 프로필로 길을 나섰네, 로컬과 개발이 반짝이네.
Swagger는 두 서버 품고 웃고,
CI는 단순해지고 CD는 파일을 써서 달리네.
설정은 이제 깃에 머무르고,
배포는 compose로 조용히 춤추네.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 '[CHORE] 로컬 / 개발 환경 분리'로, 변경사항의 핵심인 로컬과 개발 환경 분리를 명확하게 설명하고 있습니다.
Linked Issues check ✅ Passed PR이 링크된 이슈 #29의 주요 요구사항인 Spring profile 분리를 완벽하게 구현했습니다.
Out of Scope Changes check ✅ Passed CD 워크플로우 개선과 Swagger 설정 변경은 환경 분리 목표를 달성하기 위한 필요한 변경사항들입니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/cd.yml (1)

60-60: ⚠️ Potential issue | 🟠 Major

appleboy/ssh-action@master를 고정 버전(태그 또는 커밋 SHA)으로 핀닝하세요. (.github/workflows/cd.yml:60)

@master는 실행 시점마다 동작이 바뀔 수 있어 CD 공급망 리스크가 큽니다. 릴리스 태그나 가능하면 커밋 SHA로 고정하는 방식이 안전합니다.

🤖 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/cd.yml at line 60, 현재 워크플로에서 "uses:
appleboy/ssh-action@master"로 지정된 외부 액션이 태그 대신 브랜치로 참조되어 있어 공급망 리스크가 큽니다; "uses:
appleboy/ssh-action@master"을 찾아 릴리스 태그나 커밋 SHA로 교체(예: appleboy/ssh-action@vX.Y.Z
또는 appleboy/ssh-action@<commit-sha>)하도록 업데이트하고, 변경 이유를 짧게 주석으로 남기며 필요하면 액션의 최신
안정 태그/커밋을 확인해 사용하세요.
🧹 Nitpick comments (1)
src/main/java/SeCause/SeCause_be/global/config/SwaggerConfig.java (1)

37-45: ⚡ Quick win

운영 서버가 기본 선택되어 실수로 프로덕션에 요청을 보낼 위험

Swagger UI는 첫 번째로 추가된 서버를 기본값으로 사용합니다. 현재 prodServer가 먼저 추가되어 있어, 로컬 개발 시에도 Swagger UI에서 운영 서버가 기본 선택됩니다. 이로 인해 개발자가 실수로 운영 환경에 테스트 요청을 보낼 수 있습니다.

로컬 서버를 먼저 추가하여 기본 선택되도록 하는 것이 안전합니다.

♻️ 제안하는 수정 사항
         Server prodServer = new Server().url(prodServerUrl).description("운영 서버 (HTTPS)");
         Server localServer = new Server().url("http://localhost:8080").description("로컬 테스트용 (HTTP)");

         return new OpenAPI()
-                .addServersItem(prodServer)
                 .addServersItem(localServer)
+                .addServersItem(prodServer)
                 .info(info)
                 .addSecurityItem(securityRequirement)
                 .components(components);
🤖 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/java/SeCause/SeCause_be/global/config/SwaggerConfig.java` around
lines 37 - 45, In SwaggerConfig, the OpenAPI servers are added in an order that
makes prodServer the default in Swagger UI; change the order so localServer is
added before prodServer (i.e., call .addServersItem(localServer) then
.addServersItem(prodServer>) or otherwise ensure localServer is the first entry)
so that the local URL is selected by default and prevents accidental requests to
the production server; update the OpenAPI builder that currently chains
.addServersItem(prodServer).addServersItem(localServer) to add localServer first
and keep the rest (.info, .addSecurityItem, .components) unchanged.
🤖 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/cd.yml:
- Line 75: Replace the immutable image tag usage: find occurrences of the
literal string "image: ${DOCKER_REPO}:latest" used in the deploy/pull steps and
change them to use the commit SHA tag produced by the build (e.g. "image:
${DOCKER_REPO}:${{ github.sha }}"); ensure every deployment reference (including
the repeated occurrences analogous to the one shown) matches the tag the
build/push step uses so the workflow pulls the exact image built for that
commit.

In `@src/main/resources/application-local.yml`:
- Around line 26-34: 애플리케이션이 로컬에서 ENV 미설정 시 jwt.secret이 null이 되어
JwtTokenProvider에서 jwtProperties.secret().getBytes() 호출 시 NPE가 발생하므로
application-local.yml의 jwt.secret 변수에 안전한 기본값을 추가해 로컬 개발에서도 동작하도록 수정하세요; 수정 대상은
yaml의 jwt.secret: ${JWT_SECRET} 항목이며 기본값은 로컬용 임시 비밀(예: 간단한 문자열)로 설정하고 배포 환경에서는
환경변수로 덮어쓰도록 유지하십시오.

---

Outside diff comments:
In @.github/workflows/cd.yml:
- Line 60: 현재 워크플로에서 "uses: appleboy/ssh-action@master"로 지정된 외부 액션이 태그 대신 브랜치로
참조되어 있어 공급망 리스크가 큽니다; "uses: appleboy/ssh-action@master"을 찾아 릴리스 태그나 커밋 SHA로
교체(예: appleboy/ssh-action@vX.Y.Z 또는 appleboy/ssh-action@<commit-sha>)하도록 업데이트하고,
변경 이유를 짧게 주석으로 남기며 필요하면 액션의 최신 안정 태그/커밋을 확인해 사용하세요.

---

Nitpick comments:
In `@src/main/java/SeCause/SeCause_be/global/config/SwaggerConfig.java`:
- Around line 37-45: In SwaggerConfig, the OpenAPI servers are added in an order
that makes prodServer the default in Swagger UI; change the order so localServer
is added before prodServer (i.e., call .addServersItem(localServer) then
.addServersItem(prodServer>) or otherwise ensure localServer is the first entry)
so that the local URL is selected by default and prevents accidental requests to
the production server; update the OpenAPI builder that currently chains
.addServersItem(prodServer).addServersItem(localServer) to add localServer first
and keep the rest (.info, .addSecurityItem, .components) unchanged.
🪄 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 Plus

Run ID: 61e78c6a-31df-4cc3-bc1d-13c95110c950

📥 Commits

Reviewing files that changed from the base of the PR and between 5b44e0d and b76918b.

📒 Files selected for processing (7)
  • .github/workflows/cd.yml
  • .github/workflows/ci.yml
  • .gitignore
  • src/main/java/SeCause/SeCause_be/global/config/SwaggerConfig.java
  • src/main/resources/application-dev.yml
  • src/main/resources/application-local.yml
  • src/main/resources/application.yml
💤 Files with no reviewable changes (2)
  • .gitignore
  • .github/workflows/ci.yml

Comment thread .github/workflows/cd.yml
cat > docker-compose.yml <<EOF
services:
secause:
image: ${DOCKER_REPO}:latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

배포 이미지를 latest 대신 불변 태그로 고정하세요.

현재 배포가 ${DOCKER_REPO}:latest를 pull/up 하므로, 워크플로우가 연속 실행될 때 의도한 커밋이 아닌 이미지가 올라갈 수 있습니다. 빌드에서 이미 ${{ github.sha }}를 push하고 있으니 배포도 동일 SHA 태그를 사용해 원자적으로 맞추는 편이 안전합니다.

제안 변경안
       - name: Deploy to server with Docker
         uses: appleboy/ssh-action@master
         env:
           DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
+          IMAGE_TAG: ${{ github.sha }}
         with:
@@
-          envs: DOCKER_REPO
+          envs: DOCKER_REPO,IMAGE_TAG
           script: |
@@
             cat > docker-compose.yml <<EOF
             services:
               secause:
-                image: ${DOCKER_REPO}:latest
+                image: ${DOCKER_REPO}:${IMAGE_TAG}
                 container_name: secause

Also applies to: 85-86

🤖 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/cd.yml at line 75, Replace the immutable image tag usage:
find occurrences of the literal string "image: ${DOCKER_REPO}:latest" used in
the deploy/pull steps and change them to use the commit SHA tag produced by the
build (e.g. "image: ${DOCKER_REPO}:${{ github.sha }}"); ensure every deployment
reference (including the repeated occurrences analogous to the one shown)
matches the tag the build/push step uses so the workflow pulls the exact image
built for that commit.

Comment thread src/main/resources/application-local.yml
@dldusgh318 dldusgh318 merged commit a5f8d01 into SeCause:develop Jun 10, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️ CHORE 기타 변경사항 (빌드 스크립트 수정, 패키지 매니징 설정 등)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] 서버 환경 분리

1 participant