Skip to content

Conversation

@GoGradually
Copy link
Collaborator

변경된 점

  • Dockerfile 생성
  • .dockerignore 정의

Copilot AI review requested due to automatic review settings December 20, 2025 12:24
@GoGradually GoGradually changed the title build: Dockerfile 및 .dockerignore 파일 추가 build: 도커 이미지 배포 Dec 20, 2025
@GoGradually GoGradually changed the title build: 도커 이미지 배포 build/도커 이미지 배포 Dec 20, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

이 PR은 Spring Boot 애플리케이션을 컨테이너화하기 위한 Docker 설정을 추가합니다. GitHub Actions CD 워크플로우와 통합하여 이미지를 빌드하고 Kubernetes에 배포할 수 있도록 구성되었습니다.

주요 변경사항:

  • Eclipse Temurin 21 JRE 기반의 프로덕션용 Dockerfile 생성
  • 비루트 사용자(UID 10001)로 실행하여 보안 강화
  • Docker 빌드 컨텍스트 최적화를 위한 .dockerignore 설정

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
Dockerfile Eclipse Temurin 21 JRE 이미지 기반으로 Spring Boot JAR 애플리케이션을 실행하는 컨테이너 정의. 비루트 사용자 설정 및 JAR 파일 선택 로직 포함
.dockerignore Docker 빌드 컨텍스트에서 대부분의 파일을 제외하고 build/libs JAR 파일만 포함하도록 설정

COPY build/libs/*.jar /app/

RUN set -eux; \
JAR="$(ls /app/*.jar | grep -v -- '-plain\.jar$' | head -n 1)"; \
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

(1) 문제점: JAR 파일 선택 로직에서 여러 개의 non-plain JAR 파일이 존재할 경우 head -n 1을 사용하여 첫 번째 파일만 선택합니다. 이는 예측 불가능한 동작을 유발할 수 있습니다.

(2) 영향: 빌드 시 여러 버전의 JAR 파일이 존재하거나 예상치 못한 JAR 파일이 선택되어 잘못된 애플리케이션이 실행될 수 있습니다.

(3) 수정 제안: JAR 파일이 정확히 하나만 있는지 검증하는 로직을 추가하거나, 특정 패턴(예: *-SNAPSHOT.jar)을 명시적으로 지정하세요. 예: JAR_COUNT를 확인하여 1개가 아닌 경우 에러를 발생시키는 방식을 고려하세요.

Suggested change
JAR="$(ls /app/*.jar | grep -v -- '-plain\.jar$' | head -n 1)"; \
JARS="$(ls /app/*.jar | grep -v -- '-plain\.jar$' || true)"; \
JAR_COUNT="$(printf '%s\n' "$JARS" | sed '/^$/d' | wc -l)"; \
if [ "$JAR_COUNT" -ne 1 ]; then \
echo "ERROR: Expected exactly 1 non-plain JAR in /app, but found $JAR_COUNT." >&2; \
echo "Non-plain JAR candidates:" >&2; \
printf '%s\n' "$JARS" >&2; \
exit 1; \
fi; \
JAR="$(printf '%s\n' "$JARS" | sed '/^$/d')"; \

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +20
COPY build/libs/*.jar /app/

RUN set -eux; \
JAR="$(ls /app/*.jar | grep -v -- '-plain\.jar$' | head -n 1)"; \
mv "$JAR" /app/app.jar; \
rm -f /app/*-plain.jar || true; \
chown 10001:0 /app/app.jar
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

(1) 문제점: build/libs 디렉토리의 모든 JAR 파일을 복사한 후 불필요한 파일을 삭제하는 방식은 비효율적입니다. Docker 레이어 캐싱 관점에서도 최적화되어 있지 않습니다.

(2) 영향: 빌드 과정에서 불필요한 파일 복사 및 삭제 작업이 발생하며, Docker 레이어가 불필요하게 증가합니다.

(3) 수정 제안: COPY 명령 전에 plain.jar를 제외하고 복사하거나, gradle 설정에서 plain jar 생성을 비활성화(jar { enabled = false })하는 것을 권장합니다.

Copilot uses AI. Check for mistakes.
**

!Dockerfile
!k8s/**
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

(1) 문제점: .dockerignore 파일이 k8s/** 디렉토리를 포함하도록 설정되어 있지만, Dockerfile에서는 k8s 디렉토리를 사용하지 않습니다. 불필요한 파일이 Docker 빌드 컨텍스트에 포함됩니다.

(2) 영향: Docker 빌드 컨텍스트 크기가 불필요하게 증가하여 빌드 속도가 느려질 수 있습니다.

(3) 수정 제안: k8s/** 라인을 제거하세요. Dockerfile에서 실제로 필요한 build/libs/*.jar 파일만 포함하도록 .dockerignore를 단순화하는 것이 좋습니다.

Suggested change
!k8s/**

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,8 @@
**

!Dockerfile
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

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

(1) 문제점: .dockerignore 파일에서 Dockerfile 자체를 포함(!Dockerfile)하고 있는데, 이는 불필요합니다. Dockerfile은 Docker 빌드 과정에서 자동으로 처리되며 이미지 내부에 복사할 필요가 없습니다.

(2) 영향: 보안 및 이미지 크기 관점에서 불필요한 파일이 포함될 수 있습니다.

(3) 수정 제안: !Dockerfile 라인을 제거하세요.

Suggested change
!Dockerfile

Copilot uses AI. Check for mistakes.
@GoGradually GoGradually merged commit ff5751a into master Dec 20, 2025
1 check passed
@GoGradually GoGradually deleted the build/docker-이미지-배포 branch December 20, 2025 13:17
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.

2 participants