Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
FROM amazoncorretto:21
COPY build/libs/*SNAPSHOT.war app.war

ENTRYPOINT ["java", "-Duser.timezone=GMT+9", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app.war"]
ENTRYPOINT [
"java",
"-Duser.timezone=GMT+9",
"-Djava.security.egd=file:/dev/./urandom",
"-XX:+UseG1GC",
"-XX:MaxGCPauseMillis=100",
"-Xms2g",
"-Xmx2g",
Comment on lines +10 to +11

Choose a reason for hiding this comment

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

medium

힙 크기(-Xms2g, -Xmx2g)가 하드코딩되어 있습니다. 이렇게 하면 모든 환경에서 동일한 힙 크기를 사용하게 되어 유연성이 떨어질 수 있습니다. 예를 들어, 로컬 개발 환경에서는 더 작은 힙을 사용하고, 프로덕션 환경에서는 더 큰 힙을 사용해야 할 수 있습니다.

Docker 이미지 재빌드 없이 환경에 따라 힙 크기를 조절할 수 있도록 환경 변수를 사용하는 것을 고려해 보세요. 예를 들어, ENTRYPOINT를 쉘 형식으로 변경하고 HEAP_SIZE와 같은 환경 변수를 사용할 수 있습니다:

ENTRYPOINT ["/bin/sh", "-c", "exec java ... -Xms${HEAP_SIZE:-2g} -Xmx${HEAP_SIZE:-2g} ... -jar /app.war"]

"-jar", "/app.war"
]
Comment on lines +4 to +13

Choose a reason for hiding this comment

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

medium

Java 11 이상(현재 Amazon Corretto 21 사용)에서는 G1 GC가 기본 가비지 컬렉터이므로 -XX:+UseG1GC 플래그는 중복됩니다. 설정을 더 간결하게 유지하기 위해 이 플래그를 제거하는 것이 좋습니다.

ENTRYPOINT [
  "java",
  "-Duser.timezone=GMT+9",
  "-Djava.security.egd=file:/dev/./urandom",
  "-XX:MaxGCPauseMillis=100",
  "-Xms2g",
  "-Xmx2g",
  "-jar", "/app.war"
]

Loading