-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (33 loc) · 1002 Bytes
/
Dockerfile
File metadata and controls
44 lines (33 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 1단계: Gradle로 Spring Boot JAR 빌드
FROM gradle:8.10.0-jdk21-alpine AS builder
WORKDIR /app
# 의존성 캐싱 레이어
COPY build.gradle settings.gradle ./
COPY gradle gradle
COPY gradlew .
RUN chmod +x gradlew && \
./gradlew dependencies --no-daemon
# 애플리케이션 빌드
COPY src src
RUN ./gradlew bootJar --no-daemon -x test
# 2단계: 실행용 이미지 (최소화)
FROM eclipse-temurin:21-jre-alpine
# 보안: 비-root 유저 생성
RUN addgroup -S spring && adduser -S spring -G spring
WORKDIR /app
# JAR 파일만 복사
COPY --from=builder /app/build/libs/*.jar app.jar
# 소유권 변경
RUN chown spring:spring app.jar
# 비-root 유저로 전환
USER spring
EXPOSE 8080
# 성능 최적화된 JVM 옵션
ENTRYPOINT ["java", \
"-XX:+UseContainerSupport", \
"-XX:MaxRAMPercentage=75.0", \
"-XX:InitialRAMPercentage=50.0", \
"-XX:+UseG1GC", \
"-XX:+DisableExplicitGC", \
"-Djava.security.egd=file:/dev/./urandom", \
"-jar", "app.jar"]