-
Notifications
You must be signed in to change notification settings - Fork 0
build/도커 이미지 배포 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "build/docker-\uC774\uBBF8\uC9C0-\uBC30\uD3EC"
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,8 @@ | ||||
| ** | ||||
|
|
||||
| !Dockerfile | ||||
| !k8s/** | ||||
|
||||
| !k8s/** |
| 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 \ | ||||||||||||||||||||||
| && chown -R 10001:0 /app | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # GitHub Actions에서 ./gradlew clean test build 로 생성된 산출물 사용 | ||||||||||||||||||||||
| # (주의) build/libs 에 plain.jar 와 bootJar가 같이 생길 수 있어 bootJar를 선택하도록 처리 | ||||||||||||||||||||||
| COPY build/libs/*.jar /app/ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| RUN set -eux; \ | ||||||||||||||||||||||
| JAR="$(ls /app/*.jar | grep -v -- '-plain\.jar$' | head -n 1)"; \ | ||||||||||||||||||||||
|
||||||||||||||||||||||
| 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
AI
Dec 20, 2025
There was a problem hiding this comment.
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 })하는 것을 권장합니다.
There was a problem hiding this comment.
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 라인을 제거하세요.