-
Notifications
You must be signed in to change notification settings - Fork 0
build/Dockerfile 추가 및 애플리케이션 실행 환경 설정 #3
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/dockerfile-\uCD94\uAC00"
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,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 | ||
|
Comment on lines
+7
to
+10
|
||
|
|
||
| # 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)"; \ | ||
| mv "$JAR" /app/app.jar; \ | ||
|
Comment on lines
+16
to
+18
|
||
| 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
|
||
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.
문제점: WORKDIR /app을 설정한 후, RUN 명령에서 다시 mkdir -p /app을 실행하고 있습니다. WORKDIR은 디렉터리가 없으면 자동으로 생성하므로 중복된 작업입니다.
영향: 불필요한 명령어로 인해 Docker 이미지 빌드 시간이 증가하고, 코드의 명확성이 떨어집니다.
수정 제안: mkdir -p /app 명령을 제거하거나, WORKDIR 설정 전에 사용자 생성 및 디렉터리 생성을 함께 처리하는 것을 권장합니다.