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
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# syntax=docker/dockerfile:1

FROM eclipse-temurin:21-jre-jammy

WORKDIR /app

# 비루트 실행(쿠버네티스 securityContext와도 정합성 좋음)
RUN useradd -r -u 10001 -g root appuser \
&& mkdir -p /app \
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

문제점: WORKDIR /app을 설정한 후, RUN 명령에서 다시 mkdir -p /app을 실행하고 있습니다. WORKDIR은 디렉터리가 없으면 자동으로 생성하므로 중복된 작업입니다.

영향: 불필요한 명령어로 인해 Docker 이미지 빌드 시간이 증가하고, 코드의 명확성이 떨어집니다.

수정 제안: mkdir -p /app 명령을 제거하거나, WORKDIR 설정 전에 사용자 생성 및 디렉터리 생성을 함께 처리하는 것을 권장합니다.

Suggested change
&& mkdir -p /app \

Copilot uses AI. Check for mistakes.
&& chown -R 10001:0 /app
Comment on lines +7 to +10
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

문제점: Dockerfile에서 UID 10001로 비루트 사용자를 생성하여 보안을 강화했으나, Kubernetes deployment.yaml에 해당하는 securityContext 설정이 없어 정합성이 부족합니다.

영향: Dockerfile에서 설정한 보안 정책이 Kubernetes에서 명시적으로 적용되지 않아, Pod Security Standards를 준수하지 못하거나 예상치 못한 권한으로 실행될 수 있습니다.

수정 제안: k8s/deployment.yaml의 containers 섹션에 securityContext를 추가하여 runAsUser: 10001, runAsNonRoot: true, allowPrivilegeEscalation: false 등을 명시적으로 설정하는 것을 권장합니다.

Copilot generated this review using guidance from repository custom instructions.

# GitHub Actions에서 ./gradlew clean test build 로 생성된 산출물 사용
# (주의) build/libs 에 plain.jar 와 bootJar가 같이 생길 수 있어 bootJar를 선택하도록 처리
COPY build/libs/*.jar /app/
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

문제점: COPY 명령어가 와일드카드(*.jar)를 사용하고 있어, build/libs 디렉터리에 JAR 파일이 없을 경우 빌드가 실패합니다.

영향: GitHub Actions에서 빌드 과정이 실패하거나 JAR 파일이 없는 경우 Docker 빌드가 실패하여 배포 파이프라인이 중단됩니다.

수정 제안: build/libs 디렉터리를 전체 복사한 후 필터링하거나, COPY 실패 시 명확한 에러 메시지를 제공하도록 처리하는 것을 권장합니다. 또는 --chown 옵션을 사용하여 복사와 동시에 소유권을 설정할 수 있습니다.

Copilot generated this review using guidance from repository custom instructions.

RUN set -eux; \
JAR="$(ls /app/*.jar | grep -v -- '-plain\.jar$' | head -n 1)"; \
mv "$JAR" /app/app.jar; \
Comment on lines +16 to +18
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

문제점: JAR 파일을 선택하는 로직에서 JAR 파일이 하나도 없거나, grep 결과가 비어있을 때 mv 명령이 실패할 수 있습니다. 현재 'set -e'가 포함된 'set -eux'를 사용하고 있어 JAR 변수가 비어있으면 mv 명령이 실패하여 Docker 빌드가 중단됩니다.

영향: 예상치 못한 빌드 환경에서 Docker 이미지 빌드가 실패하며, 디버깅이 어려울 수 있습니다.

수정 제안: JAR 변수가 비어있는지 확인하는 검증 로직을 추가하여 명확한 에러 메시지를 제공하는 것을 권장합니다. 예: [ -z "$JAR" ] && echo "No bootJar found" && exit 1

Copilot generated this review using guidance from repository custom instructions.
rm -f /app/*-plain.jar || true; \
chown 10001:0 /app/app.jar

USER 10001

# Spring Boot 기본 포트가 8080인 경우가 많아 문서화 목적(EXPOSE는 필수 아님)
EXPOSE 8080

# JVM 옵션은 Kubernetes 매니페스트에서 JAVA_TOOL_OPTIONS로 주입 권장
ENTRYPOINT ["java","-jar","/app/app.jar"]
Comment on lines +27 to +28
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

문제점: ENTRYPOINT에서 JVM 옵션이 하드코딩되어 있지 않아 기본 설정으로 실행됩니다. 메모리 제한이 없는 환경에서는 JVM이 과도한 메모리를 사용할 수 있으며, 컨테이너 OOMKilled 위험이 있습니다.

영향: Kubernetes에서 resources.limits.memory를 512Mi로 설정했으나(k8s/deployment.yaml:77), JVM이 이를 인식하지 못하고 더 많은 메모리를 할당하려 하면 컨테이너가 종료될 수 있습니다.

수정 제안: 기본적인 JVM 메모리 설정을 ENTRYPOINT에 포함하거나, 주석에 명시된 대로 Kubernetes deployment에 JAVA_TOOL_OPTIONS 환경 변수를 추가하여 메모리 설정을 관리하는 것을 권장합니다. 예: -XX:MaxRAMPercentage=75.0

Copilot generated this review using guidance from repository custom instructions.
Loading