Skip to content

chore: 런타임베이스이미지를 Ubuntu 계열로 변경하여 apt-get 명령어가 동작할 수 있게 변경#369

Merged
wannabeing merged 1 commit intodevfrom
chore/service-dockerfile
Aug 11, 2025
Merged

chore: 런타임베이스이미지를 Ubuntu 계열로 변경하여 apt-get 명령어가 동작할 수 있게 변경#369
wannabeing merged 1 commit intodevfrom
chore/service-dockerfile

Conversation

@wannabeing
Copy link
Copy Markdown
Member

@wannabeing wannabeing commented Aug 11, 2025

🔎 작업 내용

  • 서비스 모듈의 런타임 베이스 이미지를 openjdk-17 → Ubuntu 계열(eclipse-temurin:17-jre-jammy)로 변경

런타임 베이스 이미지?

image

🧩 트러블 슈팅

배포 시, apt-get 명령어를 못찾겠다는 예외 발생

image

🧯 해결해야 할 문제

  • 기능은 동작하지만 리팩토링이나 논의가 필요한 부분을 적어주세요.
  • 예)D
    • UserController에서 비즈니스 로직 일부 처리 → 서비스로 이전 고려 필요

📌 참고 사항

  • 기타 공유하고 싶은 정보나 참고한 문서(링크 등)가 있다면 작성해주세요.

🙏 코드 리뷰 전 확인 체크리스트

  • 불필요한 콘솔 로그, 주석 제거
  • 커밋 메시지 컨벤션 준수 (type : )
  • 기능 정상 동작 확인

Summary by CodeRabbit

  • Refactor
    • 경량화된 JRE 기반 런타임으로 전환해 안정성과 일관된 실행 환경을 확보
    • 컨테이너 기본 시작 동작을 명시해 배포 후 즉시 실행 가능성 향상
  • Chores
    • 불필요한 패키지·캐시 제거로 이미지 크기 축소 및 다운로드 속도 개선
    • 추천 패키지 미설치 등 최적화로 빌드·배포 효율성 향상
    • 기본 노출 포트 8080 선언으로 서비스 연결 구성 간소화

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 11, 2025

Walkthrough

cs25-service/Dockerfile 변경: 베이스 이미지를 eclipse-temurin:17-jre-jammy로 교체하고, Node.js 설치 절차를 정리·최적화했으며, EXPOSE 8080과 ENTRYPOINT ["java","-jar","/apps/app.jar"]를 추가해 컨테이너 포트와 시작 명령을 명시했습니다.

Changes

Cohort / File(s) Change Summary
Docker 런타임/시작 설정 업데이트
cs25-service/Dockerfile
베이스 이미지 openjdk:17 → eclipse-temurin:17-jre-jammy 교체; Node.js 설치 블록을 --no-install-recommends 및 캐시/의존성 정리로 슬림화; EXPOSE 8080 추가; ENTRYPOINT ["java","-jar","/apps/app.jar"] 추가

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

토끼는 도커 속 춤을 춰, hop-hop 경쾌하게!
테무린 향 가벼운 바람, 8080 문을 열고,
자바 종을 딩-동 울리면 app.jar가 깨어나지.
캐시는 쓱쓱 비우고, 층은 깔끔 반짝!
오늘의 빌드, 귀가도 깃발처럼 펄럭 🐇🚀

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/service-dockerfile

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
🪧 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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@wannabeing wannabeing linked an issue Aug 11, 2025 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@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

🔭 Outside diff range comments (1)
cs25-service/Dockerfile (1)

43-43: ENTRYPOINT 적절합니다만, Non-root 실행과 HEALTHCHECK를 함께 고려하세요

  • 보안(필수 권장): 컨테이너를 비루트 사용자로 실행해 권한을 최소화하세요.
  • 운영(선택): Spring Boot actuator를 사용 중이라면 HEALTHCHECK를 추가해 오케스트레이터가 상태를 판단할 수 있게 하세요.

예시(파일 내 추가 코드, 위치는 COPY 이후 ENTRYPOINT 이전):

# 비루트 사용자 생성 및 권한 부여
RUN groupadd -r app && useradd -r -g app app \
 && chown -R app:app /apps
USER app

# (선택) 헬스체크 - actuator 사용 시
# HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
#   CMD curl -fsS http://localhost:8080/actuator/health || exit 1

또한(선택), 메모리 제한 환경에서의 안정성을 위해 JAVA 옵션을 환경변수로 선언하는 것도 도움이 됩니다.
예: ENV JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75.0 -XX:+UseContainerSupport"

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3e1257c and 077f29b.

📒 Files selected for processing (1)
  • cs25-service/Dockerfile (2 hunks)
🔇 Additional comments (2)
cs25-service/Dockerfile (2)

15-15: Ubuntu 계열로의 베이스 이미지 전환 적절합니다

apt-get 사용 이슈를 해결하는 방향으로 합리적입니다. 런타임은 JRE 이미지로 경량화된 점도 좋습니다.


40-40: EXPOSE 8080 명시 좋습니다

런타임 포트 명시로 운영/오케스트레이션 설정 가독성이 좋아집니다.

Comment on lines +24 to +33
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg bash \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& npm install -g @modelcontextprotocol/server-brave-search \
&& npm cache clean --force \
&& apt-get purge -y gnupg \
&& apt-get autoremove -y --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Node 설치 RUN 체인의 신뢰성/재현성/보안 개선 제안

현재 파이프(curl | bash)는 실패 전파가 약하고(기본 쉘에서 pipefail 미설정 시) 재현성(버전 고정 부재)도 떨어집니다. 아래 개선을 권장합니다.

  • 신뢰성: set -eux로 즉시 실패, 파이프 회피(스크립트 파일로 저장 후 실행).
  • 재현성: Node/글로벌 npm 패키지 버전을 고정.
  • 보안/최소권한: 글로벌 패키지 설치는 유지하되 가능하면 Non-root 사용자로 실행(아래 별도 코멘트).
  • 정리: 임시 파일 삭제, apt 리스트/캐시 정리(이미 잘 하고 계시나, apt-get clean은 선택 사항).

적용 예시(diff):

-RUN apt-get update \
- && apt-get install -y --no-install-recommends curl ca-certificates gnupg bash \
- && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
- && apt-get install -y --no-install-recommends nodejs \
- && npm install -g @modelcontextprotocol/server-brave-search \
- && npm cache clean --force \
- && apt-get purge -y gnupg \
- && apt-get autoremove -y --purge \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
+RUN set -eux; \
+  apt-get update && \
+  apt-get install -y --no-install-recommends curl ca-certificates gnupg bash && \
+  curl -fsSL -o /tmp/nodesource_setup.sh https://deb.nodesource.com/setup_20.x && \
+  bash /tmp/nodesource_setup.sh && \
+  apt-get install -y --no-install-recommends nodejs && \
+  npm install -g @modelcontextprotocol/server-brave-search@<고정버전> && \
+  npm cache clean --force && \
+  apt-get purge -y --auto-remove gnupg && \
+  rm -rf /var/lib/apt/lists/* /tmp/nodesource_setup.sh

추가로(선택): Nodesource의 공식 keyring(signed-by) 방식으로 더 명시적으로 핀ning 할 수도 있습니다. 필요하시면 해당 방식으로도 패치 제안 드리겠습니다.

아래 명령으로 기본 동작을 빠르게 확인해 보세요(지역 환경/CI 에서 실행).


🏁 Script executed:

#!/bin/bash
set -euxo pipefail
# 이미지 빌드
docker build -t cs25-service:test -f cs25-service/Dockerfile .
# apt/node/npm, 글로벌 패키지 확인
docker run --rm cs25-service:test bash -lc 'apt-get --version && node -v && npm -v && command -v mcp-brave-search-server'

Length of output: 182


🏁 Script executed:

#!/bin/bash
set -eux

# 출력: RUN 체인 부분 확인
rg -n "RUN apt-get update" -A15 cs25-service/Dockerfile

# 파이프된 스크립트 사용 여부 확인
rg -n "curl -fsSL .*\\| bash" -n cs25-service/Dockerfile

# 글로벌 패키지 버전 고정 여부 확인
rg -n "@modelcontextprotocol/server-brave-search" -n cs25-service/Dockerfile

# set -euxo pipefail 설정 여부 확인
rg -n "set .*pipefail" -n cs25-service/Dockerfile || echo "No pipefail setting found"

Length of output: 1030


Dockerfile RUN 체인에서 실패 전파·재현성·보안 개선 필요

아래 사항을 반영해 Dockerfile의 24–33라인 RUN 체인을 개선해주세요.

  • 실패 전파: set -euxo pipefail 추가 → 중간 단계 실패 시 즉시 종료
  • 스크립트 파이프 회피: curl … | bash 대신 다운로드 후 실행
  • 버전 고정: 글로벌 npm 패키지(@modelcontextprotocol/server-brave-search)에 명시적 버전 지정
  • 임시 파일·불필요 패키지 정리: --auto-remove, /tmp 파일 삭제 포함

— 수정 대상
• 파일: cs25-service/Dockerfile
• 라인: 24–33

— 예시 diff

-RUN apt-get update \
- && apt-get install -y --no-install-recommends curl ca-certificates gnupg bash \
- && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
- && apt-get install -y --no-install-recommends nodejs \
- && npm install -g @modelcontextprotocol/server-brave-search \
- && npm cache clean --force \
- && apt-get purge -y gnupg \
- && apt-get autoremove -y --purge \
- && apt-get clean \
- && rm -rf /var/lib/apt/lists/*
+RUN set -euxo pipefail; \
+    apt-get update && \
+    apt-get install -y --no-install-recommends curl ca-certificates gnupg bash && \
+    curl -fsSL -o /tmp/nodesource_setup.sh https://deb.nodesource.com/setup_20.x && \
+    bash /tmp/nodesource_setup.sh && \
+    apt-get install -y --no-install-recommends nodejs && \
+    npm install -g @modelcontextprotocol/server-brave-search@<고정버전> && \
+    npm cache clean --force && \
+    apt-get purge -y --auto-remove gnupg && \
+    rm -rf /var/lib/apt/lists/* /tmp/nodesource_setup.sh

추가로

  • 필요 시 Nodesource 공식 keyring(signed-by) 방식으로 GPG 인증 핀닝 적용 고려
  • 글로벌 설치 전용 Non-root 사용자 전환도 검토해주세요
📝 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 apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg bash \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& npm install -g @modelcontextprotocol/server-brave-search \
&& npm cache clean --force \
&& apt-get purge -y gnupg \
&& apt-get autoremove -y --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN set -euxo pipefail; \
apt-get update && \
apt-get install -y --no-install-recommends curl ca-certificates gnupg bash && \
curl -fsSL -o /tmp/nodesource_setup.sh https://deb.nodesource.com/setup_20.x && \
bash /tmp/nodesource_setup.sh && \
apt-get install -y --no-install-recommends nodejs && \
npm install -g @modelcontextprotocol/server-brave-search@<고정버전> && \
npm cache clean --force && \
apt-get purge -y --auto-remove gnupg && \
rm -rf /var/lib/apt/lists/* /tmp/nodesource_setup.sh
🤖 Prompt for AI Agents
In cs25-service/Dockerfile around lines 24 to 33, the RUN chain must be hardened
for failure propagation, reproducibility and security: prepend a shell safety
header (set -euxo pipefail) to the RUN, replace the curl | bash pattern by
downloading the NodeSource setup script to a temporary file, verify/execute it
explicitly (or prefer the signed-by keyring method to add the NodeSource apt
repo), then install nodejs; install @modelcontextprotocol/server-brave-search
with an explicit pinned version (e.g.
@modelcontextprotocol/server-brave-search@x.y.z) rather than latest; use apt-get
install with --no-install-recommends and --auto-remove where appropriate and
purge unnecessary packages in the same RUN, clean apt lists, remove /tmp and any
downloaded setup script, and clear npm cache; optionally switch to a non-root
user before the global npm install if global install is required for runtime.

@wannabeing wannabeing merged commit 132fe02 into dev Aug 11, 2025
2 checks passed
@wannabeing wannabeing deleted the chore/service-dockerfile branch August 11, 2025 08:02
wannabeing added a commit that referenced this pull request Aug 11, 2025
* chore: MCP 도입할 때 필요한 npx 패키지 적용 (#367)

* chore: MCP 도입할 때 필요한 npx 패키지 적용

* chore: 부팅 시 외부 프로세스 미실행 (요청 시 연결)

* chore: 런타임베이스이미지를 Ubuntu 계열로 변경하여 apt-get 명령어가 동작할 수 있게 변경 (#369)

---------

Co-authored-by: Ksr-ccb <harang4282@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: baegjonghyeon <baek011226@naver.com>
Co-authored-by: Baek jonghyun <69610809+jong-0126@users.noreply.github.com>
Co-authored-by: crocusia <132359536+crocusia@users.noreply.github.com>
Co-authored-by: Kimyoonbeom <101162650+Kimyoonbeom@users.noreply.github.com>
Co-authored-by: HeeMang-Lee <hemsej018@naver.com>
Co-authored-by: Kimyoonbeom <kimybeom@naver.com>
Co-authored-by: crocusia <rainbowsubin0522@gmail.com>
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.

[08.11]10차 배포 후 백엔드 모든 요청에 502에러 반환

4 participants