Skip to content

Conversation

@LeeCh0129
Copy link
Contributor

@LeeCh0129 LeeCh0129 commented Jul 17, 2025

📌 변경 사항 개요

OCI Always Free 서버에 글로벌 노마드 프로젝트를 배포하고, Docker와 GitHub Actions를 활용한 CI/CD 파이프라인을 구축했습니다.

📝 상세 내용

1. 서버 환경 구축 문서화

  • OCI 인스턴스 생성부터 초기 배포까지의 전체 과정 문서화
  • 며칠간의 트러블 슈팅 과정 포함(iptables 네트워크 문제 해결)

2. Docker 컨테이너화

  • Dockerfile: 멀티 스테이지 빌드로 이미지 크기 최적화
    • 3단계 빌드: deps -> builder -> runner
    • Alpine Linux 기반, non-root 사용자 실행
  • next.config.ts: standalone 모드 설정
  • .dockerignore: 불필요한 파일 제외로 빌드 속도 향상

3. Nginx + SSL 인프라 구축

  • docker-compose.yml: 3개 서비스 구성

    • Nextjs(환경변수로 이미지 지정)
    • Nginx(리버스 프록시, HTTPS)
    • Certbot(Let's Encrypt 자동 갱신)
  • Nginx 설정:

    • HTTP->HTTPS 리다이렉트
  • 도메인: globalnomad.site

4. CI/CD 파이프라인

CI

  • 트리거: PR 생성/업데이트 시
  • 검증단계: TS 타입 체크 -> ESLint -> 빌드 테스트
  • pnpm 캐싱으로 빠른 실행

CD

  • 배포: GHCR 배포 방식

  • 보안: PAT 사용, 불변 태그 관리

  • 프로세스 :

    1. 깃허브 러너에서 도커 이미지 빌드(OOM 방지)
    2. GHCR에 이미지 푸시
    3. SSH로 서버 접속 후 이미지 pull & 실행
  • 롤백 지원: 이전 버전 기록 및 복구

🔗 관련 이슈

🖼️ 스크린샷(선택사항)

💡 참고 사항

[TIL-OCI 인프라 구축] #34

  • PR 머지 후 본격적으로 테스트 예정(머지되면 자동으로 배포되는지, SSL 적용 등)

Summary by CodeRabbit

Summary by CodeRabbit

  • 새로운 기능

    • Docker 및 컨테이너 기반 배포를 위한 Dockerfile, docker-compose.yml, .dockerignore 파일이 추가되었습니다.
    • GitHub Actions를 통한 CI(코드 품질 검사) 및 자동 배포 워크플로우가 도입되었습니다.
    • Nginx 및 Certbot을 활용한 SSL 인증서 자동화 및 리버스 프록시 구성이 추가되었습니다.
    • Next.js 스탠드얼론 빌드 모드가 활성화되었습니다.
    • SSL 인증서 자동 발급 및 갱신을 위한 스크립트(init-letsencrypt.sh)가 추가되었습니다.
  • 문서화

    • ESLint 코드 스타일 통합을 위한 패키지가 추가되었습니다.

@LeeCh0129 LeeCh0129 self-assigned this Jul 17, 2025
@LeeCh0129 LeeCh0129 added 🌏 Deploy 배포 💻 chore 사소한 수정(빌드,패키지매니저등) labels Jul 17, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 17, 2025

"""

Walkthrough

이 변경 사항은 Docker 기반 배포와 CI/CD 파이프라인을 구축하기 위한 주요 인프라 파일들을 추가 및 수정합니다. Dockerfile, docker-compose, Nginx, Certbot, GitHub Actions 워크플로우, Next.js 설정 등이 포함되어 있으며, 자동화된 배포 및 인증서 관리가 가능하도록 구성되었습니다.

Changes

파일/경로 변경 요약
.dockerignore, Dockerfile, docker-compose.yml Docker 빌드 컨텍스트 최적화, 멀티스테이지 빌드, 서비스 정의 및 네트워크 구성 추가
.github/workflows/ci.yml, .github/workflows/deploy.yml GitHub Actions 기반 CI 및 배포 워크플로우 추가 및 설정
init-letsencrypt.sh Let's Encrypt 인증서 자동 발급 및 Nginx 초기화 스크립트 추가
next.config.ts Next.js standalone 모드 활성화 및 관련 주석 추가
nginx/conf.d/default.conf, nginx/nginx.conf Nginx 리버스 프록시, 보안, gzip, 인증서 및 캐시 설정 등 신규 구성 파일 추가
package.json eslint-config-prettier 개발 의존성 추가

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub
    participant CI
    participant GHCR
    participant RemoteServer
    participant Nginx
    participant Certbot

    Developer->>GitHub: PR 생성/병합 또는 develop 브랜치 push
    GitHub->>CI: CI/CD 워크플로우 트리거
    CI->>CI: 의존성 설치, 타입체크, 린트, 빌드
    CI->>GHCR: Docker 이미지 빌드 및 푸시
    CI->>RemoteServer: SSH로 배포 스크립트 실행
    RemoteServer->>GHCR: 최신 이미지 pull
    RemoteServer->>Nginx: 컨테이너 재시작
    Nginx->>Certbot: 인증서 갱신 요청(webroot)
    Certbot->>Nginx: 인증서 갱신 후 Nginx 재시작
    Developer->>GitHub: 배포 결과 확인
Loading

Assessment against linked issues

Objective Addressed Explanation
OCI 서버 환경 구축 및 초기 배포 관련 설정 및 배포 (#15)
Dockerfile 작성 및 Next.js standalone 모드 설정 (#16)
docker-compose.yml 작성 및 서비스 구성 (#16)
GitHub Actions CI 및 배포 워크플로우 작성 (#16)
자동 배포 스크립트 작성 및 테스트 (#16)

Assessment against linked issues: Out-of-scope changes

(없음)

Suggested labels

✨ Feature

Poem

🐇
Docker 바람 타고 구름 위로,
Nginx와 Certbot이 춤을 추네.
CI/CD 물결 따라 자동 배포,
깃허브 액션에 토끼도 감탄해!
글로벌 유목민, 이제 더 빠르게,
안전하게 세상을 누벼요!
🌍🚀
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6303a24 and 3c73d7b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 4

🧹 Nitpick comments (10)
.github/workflows/ci.yml (4)

16-16: YAML 포맷팅 문제를 수정해주세요.

줄 끝에 불필요한 공백이 있습니다.

-    runs-on: ubuntu-latest
-    
+    runs-on: ubuntu-latest
+

22-22: YAML 포맷팅 문제를 수정해주세요.

줄 끝에 불필요한 공백이 있습니다.

-          fetch-depth: 0  
+          fetch-depth: 0

37-38: Shellcheck 경고를 수정해주세요.

변수 확장 시 더블 쿼트가 필요합니다.

-          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
+          echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_ENV"

59-59: 파일 끝에 개행 문자를 추가해주세요.

YAML 표준에 따라 파일 끝에 개행 문자가 필요합니다.

-        run: pnpm build
+        run: pnpm build
+
init-letsencrypt.sh (2)

5-5: 사용되지 않는 변수를 제거하거나 활용해주세요.

rsa_key_size 변수가 정의되어 있지만 사용되지 않고 있습니다.

-rsa_key_size=4096

또는 임시 인증서 생성 시 활용하도록 수정:

-  -c "openssl req -x509 -nodes -newkey rsa:1024 -days 1 \
+  -c "openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1 \

7-7: 하드코딩된 이메일 주소를 환경 변수로 변경하는 것을 고려해주세요.

보안과 재사용성을 위해 이메일 주소를 환경 변수로 관리하는 것이 좋습니다.

-email="[email protected]"
+email="${LETSENCRYPT_EMAIL:[email protected]}"
nginx/conf.d/default.conf (1)

55-59: 정적 자산을 프록시로 우회하면 불필요한 오버헤드 발생

/_next/static 경로는 Nginx가 직접 서빙하도록 root/alias 로 매핑하면

  • 컨테이너 간 트래픽 감소
  • 캐시 헤더 강제 가능

예:

-    location /_next/static {
-        proxy_pass http://nextjs:3000;
-        proxy_cache_valid 60m;
-        add_header Cache-Control "public, immutable";
-    }
+    location /_next/static {
+        alias /app/.next/static;  # docker-volume 로 마운트 필요
+        expires 60m;
+        add_header Cache-Control "public, immutable";
+    }
Dockerfile (1)

59-67: 헬스체크 명령이 없어 오케스트레이션 도구가 상태를 판단할 수 없습니다

Docker 이미지에 HEALTHCHECK 를 추가하면 docker ps 혹은 compose healthcheck
연동되어 배포 스크립트가 더 신뢰성 있게 실패를 감지할 수 있습니다.

+# 컨테이너 헬스체크
+HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
+  CMD wget -qO- http://localhost:3000/ || exit 1
nginx/nginx.conf (1)

36-40: 서버 버전 노출 방지를 위한 server_tokens off; 권장

공격 표면 축소를 위해 전역 http 블록에 아래 항목을 추가해 주십시오.

+    server_tokens off;
.github/workflows/deploy.yml (1)

150-157: ShellCheck SC2086: 인용 누락

curl -f http://localhost:3000 에 변수는 없지만, 다른 곳(docker images | grep global-nomad | tail -n +4 ...) 등에서
단어 분할 위험이 있습니다. 정적 분석 경고를 최소화하고 안전성을 높이려면
각 명령의 변수 부분을 이중 인용해 주세요.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e03c77 and d145c3b.

📒 Files selected for processing (9)
  • .dockerignore (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/deploy.yml (1 hunks)
  • Dockerfile (1 hunks)
  • docker-compose.yml (1 hunks)
  • init-letsencrypt.sh (1 hunks)
  • next.config.ts (1 hunks)
  • nginx/conf.d/default.conf (1 hunks)
  • nginx/nginx.conf (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

37-37: shellcheck reported issue in this script: SC2086:info:1:50: Double quote to prevent globbing and word splitting

(shellcheck)

.github/workflows/deploy.yml

54-54: shellcheck reported issue in this script: SC2086:info:1:51: Double quote to prevent globbing and word splitting

(shellcheck)


54-54: shellcheck reported issue in this script: SC2086:info:2:55: Double quote to prevent globbing and word splitting

(shellcheck)


84-84: shellcheck reported issue in this script: SC2086:info:1:107: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 16-16: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 59-59: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/deploy.yml

[error] 26-26: trailing spaces

(trailing-spaces)


[error] 32-32: trailing spaces

(trailing-spaces)


[error] 37-37: trailing spaces

(trailing-spaces)


[error] 93-93: trailing spaces

(trailing-spaces)


[error] 114-114: trailing spaces

(trailing-spaces)


[error] 117-117: trailing spaces

(trailing-spaces)


[error] 121-121: trailing spaces

(trailing-spaces)


[error] 125-125: trailing spaces

(trailing-spaces)


[error] 130-130: trailing spaces

(trailing-spaces)


[error] 134-134: trailing spaces

(trailing-spaces)


[error] 138-138: trailing spaces

(trailing-spaces)


[error] 142-142: trailing spaces

(trailing-spaces)


[error] 147-147: trailing spaces

(trailing-spaces)


[error] 158-158: trailing spaces

(trailing-spaces)


[error] 165-165: trailing spaces

(trailing-spaces)


[error] 171-171: trailing spaces

(trailing-spaces)


[error] 175-175: trailing spaces

(trailing-spaces)


[error] 190-190: no new line character at the end of file

(new-line-at-end-of-file)

🪛 Shellcheck (0.10.0)
init-letsencrypt.sh

[warning] 5-5: rsa_key_size appears unused. Verify use (or export if used externally).

(SC2034)

🔇 Additional comments (10)
.dockerignore (1)

1-52: Docker 빌드 최적화를 위한 포괄적인 .dockerignore 구성이 잘 되어 있습니다.

파일 구성이 체계적이고 Docker 빌드 컨텍스트 최적화를 위한 필수 항목들이 모두 포함되어 있습니다:

  • 의존성 및 빌드 아티팩트 제외
  • 개발/테스트 관련 파일 제외
  • 환경 설정 파일 보안 제외
  • 문서 및 Docker 관련 파일 제외
.github/workflows/ci.yml (1)

1-59: CI 워크플로우 구성이 잘 되어 있습니다.

pnpm 캐싱을 활용한 효율적인 CI 파이프라인이 구성되어 있고, 코드 품질 검사 단계가 적절히 포함되어 있습니다.

next.config.ts (1)

4-6: Docker 배포를 위한 standalone 모드 설정이 적절합니다.

standalone 모드는 Docker 컨테이너에서 Next.js 애플리케이션을 실행하는 데 최적화된 설정입니다. 필요한 파일만 포함하여 이미지 크기를 최소화할 수 있습니다.

docker-compose.yml (4)

8-8: 환경 변수 기본값이 적절히 설정되어 있습니다.

GHCR 이미지를 기본값으로 하면서 환경 변수로 오버라이드 가능한 구조가 좋습니다.


28-34: SSL 인증서 볼륨 마운트 설정이 적절합니다.

Nginx와 Certbot 간의 인증서 공유를 위한 볼륨 마운트가 올바르게 구성되어 있습니다.


52-54: 네트워크 구성이 보안성을 고려하여 잘 설정되어 있습니다.

커스텀 브리지 네트워크를 사용하여 서비스 간 격리와 통신을 적절히 관리하고 있습니다.


39-39: Nginx 명령어의 보안 취약점을 수정해주세요.

현재 명령어는 shell injection에 취약할 수 있습니다. 더 안전한 방식으로 변경하는 것을 권장합니다.

-    command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
+    command: >
+      /bin/sh -c "
+        while :; do
+          sleep 6h &
+          wait $$!
+          nginx -s reload
+        done &
+        nginx -g 'daemon off;'
+      "

Likely an incorrect or invalid review comment.

init-letsencrypt.sh (3)

36-46: 임시 인증서 생성 로직이 적절합니다.

Nginx 시작을 위한 임시 자체 서명 인증서 생성이 올바르게 구현되어 있습니다.


62-84: Let's Encrypt 인증서 요청 로직이 잘 구현되어 있습니다.

스테이징 모드와 프로덕션 모드를 선택할 수 있는 구조가 rate limit 회피에 도움이 됩니다.


8-9: 스테이징 모드 설정이 적절합니다.

테스트 단계에서 rate limit을 회피하기 위한 스테이징 모드 활용이 좋은 접근입니다.

Comment on lines +24 to +35
# SSL 인증서 경로 (Let's Encrypt)
ssl_certificate /etc/letsencrypt/live/globalnomad.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/globalnomad.site/privkey.pem;

# SSL 설정
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;

# HSTS (HTTPS 강제)
add_header Strict-Transport-Security "max-age=63072000" always;

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

SSL 설정이 최소화되어 있어 세션 캐시·HSTS 옵션이 부족합니다

ssl_certificate만 지정되어 있고 세션 캐시(ssl_session_cache, ssl_session_timeout)가 빠져 있어 TLS 핸드셰이크가 매번 재협상됩니다.
또한 HSTS 헤더에 includeSubDomains; preload 가 빠져 있어 하위 도메인 혹은 프리로드 등록 시 효력이 없습니다.

+    # 성능 및 보안 강화
+    ssl_session_cache   shared:SSL:10m;
+    ssl_session_timeout 1h;

-    add_header Strict-Transport-Security "max-age=63072000" always;
+    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
📝 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.

Suggested change
# SSL 인증서 경로 (Let's Encrypt)
ssl_certificate /etc/letsencrypt/live/globalnomad.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/globalnomad.site/privkey.pem;
# SSL 설정
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# HSTS (HTTPS 강제)
add_header Strict-Transport-Security "max-age=63072000" always;
# SSL 인증서 경로 (Let's Encrypt)
ssl_certificate /etc/letsencrypt/live/globalnomad.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/globalnomad.site/privkey.pem;
# SSL 설정
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# 성능 및 보안 강화
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1h;
# HSTS (HTTPS 강제)
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
🤖 Prompt for AI Agents
In nginx/conf.d/default.conf around lines 24 to 35, the SSL configuration lacks
session cache settings and complete HSTS options. Add ssl_session_cache and
ssl_session_timeout directives to enable TLS session caching and reduce
handshake overhead. Also, update the Strict-Transport-Security header to include
includeSubDomains and preload directives to enforce HSTS on subdomains and allow
preloading.

Comment on lines +36 to +52
# Next.js로 프록시
location / {
proxy_pass http://nextjs:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;

# 타임아웃 설정
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

프록시 헤더 및 본문 크기 제한 누락

  1. 업그레이드-헤더는 설정했지만 proxy_set_header X-Forwarded-Host $host 가 없어 원본 호스트 정보가 유실됩니다.
  2. 기본 client_max_body_size(1 MB) 제한을 조정하지 않으면 대용량 파일 업로드 시 413 오류가 발생합니다.
  3. WebSocket 사용 시 proxy_buffering off; 를 추가하면 지연을 줄일 수 있습니다.
+        client_max_body_size 20m;
+        proxy_set_header X-Forwarded-Host $host;
+        proxy_buffering off;
📝 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.

Suggested change
# Next.js로 프록시
location / {
proxy_pass http://nextjs:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
# 타임아웃 설정
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Next.js로 프록시
location / {
proxy_pass http://nextjs:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
client_max_body_size 20m;
proxy_set_header X-Forwarded-Host $host;
proxy_buffering off;
# 타임아웃 설정
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
🤖 Prompt for AI Agents
In nginx/conf.d/default.conf around lines 36 to 52, the proxy configuration is
missing the header 'proxy_set_header X-Forwarded-Host $host' which causes loss
of original host information; add this header to preserve it. Also, increase the
'client_max_body_size' directive to allow larger request bodies and prevent 413
errors during large file uploads. Finally, add 'proxy_buffering off;' to the
location block to reduce latency for WebSocket connections.

Comment on lines +45 to +48
# 시스템 사용자 생성
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

사용자·그룹 ID 불일치 가능성

addgroup --system --gid 1001 nodejs 로 그룹을 만들었지만 adduser 시 그룹을 지정하지 않아
nextjs 사용자가 기본 그룹(동일 이름)으로 생성됩니다. 아래처럼 명시적으로 연결해 주세요.

-RUN addgroup --system --gid 1001 nodejs
-RUN adduser --system --uid 1001 nextjs
+RUN addgroup --system --gid 1001 nodejs \
+ && adduser  --system --uid 1001 --ingroup nodejs nextjs
📝 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.

Suggested change
# 시스템 사용자 생성
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# 시스템 사용자 생성
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 --ingroup nodejs nextjs
🤖 Prompt for AI Agents
In the Dockerfile at lines 45 to 48, the group 'nodejs' is created with GID
1001, but the user 'nextjs' is added without specifying this group, causing a
mismatch. Fix this by explicitly assigning the 'nodejs' group to the 'nextjs'
user during creation using the appropriate adduser option to link the user to
the 'nodejs' group.

Comment on lines +104 to +115
env:
IMAGE_URL: ${{ needs.build.outputs.image-url }}
GIT_SHA: ${{ needs.build.outputs.git-sha }}
run: |
ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << 'ENDSSH'
set -e

echo "📦 Starting deployment..."
echo "🏷️ Image: ${IMAGE_URL}"
echo "🔖 Version: ${GIT_SHA}"

# 프로젝트 디렉토리로 이동
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

원격 SSH 스크립트에서 IMAGE_URL, GIT_SHA 가 비어 있습니다

env: 로 설정한 변수는 로컬 셸에만 주입되며,
ssh <<'ENDSSH' 는 작은따옴표 덕분에 로컬 확장을 막아 원격 측에는 전달되지 않습니다.
결과적으로 docker pull ${IMAGE_URL} 가 빈 문자열로 실행되어 실패합니다.

다음 중 한 가지로 해결하세요.

  1. 여기-문을 큰따옴표로 변경하고 변수를 로컬에서 치환
  2. SSH SendEnv 사용
  3. echo/EXPORT 방식으로 값 삽입

가장 간단한 수정 예시:

-          ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << 'ENDSSH'
+          ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << ENDSSH

또는:

-          ssh -i ~/.ssh/id_rsa ...
+          ssh -i ~/.ssh/id_rsa -o SendEnv=IMAGE_URL -o SendEnv=GIT_SHA ...
📝 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.

Suggested change
env:
IMAGE_URL: ${{ needs.build.outputs.image-url }}
GIT_SHA: ${{ needs.build.outputs.git-sha }}
run: |
ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << 'ENDSSH'
set -e
echo "📦 Starting deployment..."
echo "🏷️ Image: ${IMAGE_URL}"
echo "🔖 Version: ${GIT_SHA}"
# 프로젝트 디렉토리로 이동
env:
IMAGE_URL: ${{ needs.build.outputs.image-url }}
GIT_SHA: ${{ needs.build.outputs.git-sha }}
run: |
- ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << 'ENDSSH'
+ ssh -i ~/.ssh/id_rsa ${{ secrets.OCI_USERNAME }}@${{ secrets.OCI_HOST }} << ENDSSH
set -e
echo "📦 Starting deployment..."
echo "🏷️ Image: ${IMAGE_URL}"
echo "🔖 Version: ${GIT_SHA}"
# 프로젝트 디렉토리로 이동
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 114-114: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In .github/workflows/deploy.yml around lines 104 to 115, the environment
variables IMAGE_URL and GIT_SHA set under env are not passed into the remote SSH
session because the here-document uses single quotes, preventing variable
expansion. To fix this, change the here-document delimiter from 'ENDSSH' to
ENDSSH without quotes so that the variables are expanded locally before being
sent to the remote shell. This ensures IMAGE_URL and GIT_SHA have their intended
values during the remote commands.

@evaain706
Copy link
Contributor

인프라 세팅 정말 수고많으셨습니다!
예전 vercel로 할때 yml하나 작성할때도 머리가 아팠었는데
이번에 구현하신방식은 비교가 안되게 복잡하군요....

Copy link
Contributor

@BokyungCodes BokyungCodes left a comment

Choose a reason for hiding this comment

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

배포 자동화 환경 구축해주신 것,, 인프라에 큰 기여 해주신 점,, 정말 감사합니다!!
너무너무 고생하셨어요 💪

Copy link

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

15-23: 불필요한 공백(trailing space) 정리 필요

16, 22번째 줄 끝에 불필요한 공백이 감지됩니다. YAML 파싱에는 문제 없지만 린터 경고가 계속 발생하므로 삭제를 권장합니다.
또한 EOF(62번째 줄)에도 개행이 없다고 YAMLlint가 지적하니 함께 수정해 주세요.


61-62: Build 단계만 존재—테스트 실행 검토

pnpm build만 수행되고 단위/통합 테스트 단계가 없습니다. 최소한 pnpm test 단계 추가 여부를 검토해 주세요. CI가 빌드 성공만으로 품질을 담보하긴 어렵습니다.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35756fb and 6303a24.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 16-16: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 55-55: trailing spaces

(trailing-spaces)


[error] 62-62: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.github/workflows/ci.yml (1)

24-28: Node.js 22 사용 여부 재검토

Node 22는 아직 LTS가 아니므로, 팀・프로덕션 환경 전체가 동일 버전을 사용 중인지 확인이 필요합니다.
만약 LTS 안정성을 선호한다면 node-version: '20'(현재 LTS)로 지정하거나, 매트릭스를 사용해 LTS & Current 두 버전을 모두 테스트하도록 조정해 보세요.

Comment on lines +56 to +59
- name: Lint code
# 린트오류가 발생해도 CI가 실패하지 않도록 임시 설정 - 메인 배포때 옵션 제거 예정
continue-on-error: true
run: pnpm lint
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

continue-on-error: true로 린트 무력화—배포 전 해제 계획 명시 필요

린트 단계에서 오류가 나도 CI가 통과하도록 설정되어 있습니다. 임시 설정이라고 주석을 달았지만, 실제로는 쉽게 잊혀질 수 있습니다.

  1. 메인 브랜치 머지 전 반드시 제거하도록 이슈/티켓에 명시하거나,
  2. if: github.ref != 'refs/heads/main' 조건으로 메인에선 실패하도록 분기하는 방식을 고려해 주세요.
🤖 Prompt for AI Agents
In .github/workflows/ci.yml around lines 56 to 59, the lint step uses
continue-on-error: true which disables failure on lint errors. To ensure this
temporary setting is not forgotten before main branch deployment, either create
an explicit issue or ticket to remove this flag before merging to main, or
modify the workflow to conditionally apply continue-on-error only on non-main
branches by adding an if condition like if: github.ref != 'refs/heads/main' so
that lint errors fail the CI on main branch.

@minimo-9
Copy link
Contributor

인프라 세팅하시느라 고생 많으셨습니다 많이 어려워보이는데 대단하십니다!

@LeeCh0129 LeeCh0129 merged commit fb0e1c1 into develop Jul 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 chore 사소한 수정(빌드,패키지매니저등) 🌏 Deploy 배포

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[deploy] Docker 기반 CI/CD 파이프라인 구축 [deploy] OCI 서버 환경 구축 및 초기 배포

5 participants