Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions cs25-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY cs25-common cs25-common/

# 테스트 생략하여 빌드 안정화
RUN ./gradlew :cs25-service:bootJar --stacktrace --no-daemon
FROM openjdk:17
FROM eclipse-temurin:17-jre-jammy

# 메타 정보
LABEL type="application" module="cs25-service"
Expand All @@ -21,12 +21,17 @@ LABEL type="application" module="cs25-service"
WORKDIR /apps

# Node.js + npm 설치 후, MCP 서버 전역 설치
RUN apt-get update && apt-get install -y curl ca-certificates gnupg \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g @modelcontextprotocol/server-brave-search \
&& node -v && npm -v && which server-brave-search \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
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/*
Comment on lines +24 to +33
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.



# jar 복사
COPY --from=builder /build/cs25-service/build/libs/*.jar app.jar
Expand Down