Skip to content
Merged
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ ARG MODULE=apis
WORKDIR /app

# 의존성 캐싱 최적화를 위한 단계별 복사
# 1. 의존성 관련 파일만 먼저 복사
COPY build.gradle settings.gradle ./
COPY ${MODULE}/build.gradle ./${MODULE}/
# 1. Gradle Wrapper와 의존성 관련 파일만 먼저 복사
COPY build.gradle.kts settings.gradle.kts gradlew gradlew.bat ./
COPY gradle/wrapper/ ./gradle/wrapper/
COPY ${MODULE}/build.gradle.kts ./${MODULE}/

# 2. 소스코드 없이 의존성만 다운로드
# 2. Gradle Wrapper 실행 권한 부여
RUN chmod +x gradlew

Comment on lines +12 to +14
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

RUN 결합으로 레이어 축소 가능

dev Dockerfile와 동일하게 chmod + 의존성 다운로드를 하나의 RUN으로 합칠 수 있습니다. 필요 시 참고하십시오.

🤖 Prompt for AI Agents
In Dockerfile around lines 12 to 14, the RUN command for setting execute
permission on gradlew can be combined with the dependency download RUN command
to reduce image layers. Locate the RUN command that downloads dependencies and
merge the chmod +x gradlew command into it using && to execute both in a single
RUN instruction.

# 3. 소스코드 없이 의존성만 다운로드
RUN ./gradlew :${MODULE}:dependencies --no-daemon

# 3. 소스코드 전체 복사
# 4. 소스코드 전체 복사
COPY . .

# 4. 실제 애플리케이션 빌드
# 5. 실제 애플리케이션 빌드
RUN ./gradlew :${MODULE}:bootJar --parallel --no-daemon

# Run stage
Expand Down
20 changes: 12 additions & 8 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ ARG MODULE=apis
WORKDIR /app

# 의존성 캐싱 최적화를 위한 단계별 복사
# 1. 의존성 관련 파일만 먼저 복사
COPY build.gradle settings.gradle ./
COPY ${MODULE}/build.gradle ./${MODULE}/
# 1. Gradle Wrapper와 의존성 관련 파일만 먼저 복사
COPY build.gradle.kts settings.gradle.kts gradlew gradlew.bat ./
COPY gradle/wrapper/ ./gradle/wrapper/
COPY ${MODULE}/build.gradle.kts ./${MODULE}/

# 2. 소스코드 없이 의존성만 다운로드
# 2. Gradle Wrapper 실행 권한 부여
RUN chmod +x gradlew

Comment on lines +12 to +14
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

RUN 레이어 병합 고려

RUN chmod +x gradlew 뒤에 바로 의존성 다운로드를 이어서 실행하면 레이어 하나를 줄일 수 있습니다.

-RUN chmod +x gradlew
-
-# 3. 소스코드 없이 의존성만 다운로드
-RUN ./gradlew :${MODULE}:dependencies --no-daemon
+# 2-3. Wrapper 실행권한 부여 후 의존성만 다운로드
+RUN chmod +x gradlew \
+ && ./gradlew :${MODULE}:dependencies --no-daemon

캐시 히트율은 동일하니 용량 절감이 필요하다면 고려해 보세요.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# 2. Gradle Wrapper 실행 권한 부여
RUN chmod +x gradlew
# 의존성 캐싱 최적화를 위한 단계별 복사
# 1. Gradle Wrapper와 의존성 관련 파일만 먼저 복사
COPY build.gradle.kts settings.gradle.kts gradlew gradlew.bat ./
COPY gradle/wrapper/ ./gradle/wrapper/
COPY ${MODULE}/build.gradle.kts ./${MODULE}/
# 2-3. Wrapper 실행권한 부여 후 의존성만 다운로드
RUN chmod +x gradlew \
&& ./gradlew :${MODULE}:dependencies --no-daemon
# 4. 소스코드 전체 복사 (secret 폴더 포함)
COPY . .
# 5. 실제 애플리케이션 빌드
RUN ./gradlew :${MODULE}:bootJar --parallel --no-daemon
🤖 Prompt for AI Agents
In Dockerfile-dev around lines 12 to 14, the RUN command for setting execute
permission on gradlew should be combined with the subsequent dependency download
command into a single RUN statement. This reduces the number of image layers and
saves space without affecting cache efficiency. Modify the Dockerfile to merge
these commands using '&&' so they run in one layer.

# 3. 소스코드 없이 의존성만 다운로드
RUN ./gradlew :${MODULE}:dependencies --no-daemon

# 3. 소스코드 전체 복사
# 4. 소스코드 전체 복사
COPY . .

# 4. 실제 애플리케이션 빌드
# 5. 실제 애플리케이션 빌드
RUN ./gradlew :${MODULE}:bootJar --parallel --no-daemon

# Run stage
Expand All @@ -29,6 +33,6 @@ COPY --from=build /app/${MODULE}/build/libs/${MODULE}-*.jar app.jar
COPY --from=build /app/secret ./secret/

# JVM 실행 설정
# Xms512m: 초기 힙 메모리 512MB
# Xmx1g: 최대 힙 메모리 1GB
# - Xms512m: 초기 힙 메모리 512MB
# - Xmx1g: 최대 힙 메모리 1GB
Comment on lines +36 to +37
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

메모리 옵션을 ENV 로 분리 제안

ENTRYPOINT 인수에 직접 힙 옵션을 박아두면 변경 시 불필요한 이미지 재빌드가 발생합니다.

ENV JAVA_OPTS="-Xms512m -Xmx1g"
ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS -jar app.jar"]

운영 환경별로 JVM 옵션을 주입해야 할 경우 유연성이 커집니다.

🤖 Prompt for AI Agents
In Dockerfile-dev around lines 36 to 37, the JVM heap memory options are
hardcoded directly in the ENTRYPOINT, causing unnecessary image rebuilds when
changed. Refactor by moving the heap memory options into an ENV variable named
JAVA_OPTS, then update the ENTRYPOINT to use this variable. This allows easier
modification of JVM options per environment without rebuilding the image.

ENTRYPOINT ["java", "-Xms512m", "-Xmx1g", "-jar", "app.jar"]