FROM openjdk:17

ARG JAR_FILE=build/libs/CaliverseAdminAPI-qa.jar

COPY ${JAR_FILE} admintool.jar
ENTRYPOINT ["java", \
    "-Xms1g", \
    "-Xmx2g", \

    # GC 설정 (G1GC 최적화)
    "-XX:+UseG1GC", \
    "-XX:MaxGCPauseMillis=100", \
    "-XX:G1HeapRegionSize=8m", \
    "-XX:InitiatingHeapOccupancyPercent=20", \

    # OutOfMemoryError 대응
    "-XX:+HeapDumpOnOutOfMemoryError", \
    "-XX:HeapDumpPath=/logs/heapdump-%t.hprof", \
    "-XX:+ExitOnOutOfMemoryError", \

    # GC 로깅 (문제 분석용)
    "-Xlog:gc*:logs/gc.log:time,tags", \
    "-XX:+UseStringDeduplication", \

    # 메모리 최적화
    "-XX:+UseCompressedOops", \
    "-XX:+UseCompressedClassPointers", \
    "-XX:+UseStringDeduplication", \
    "-XX:MaxMetaspaceSize=256m", \

    # 네트워크 최적화
    "-Djava.net.preferIPv4Stack=true", \

    "-Djava.io.tmpdir=/tmp", \
    "-Dfile.encoding=UTF-8", \
    "-Djava.awt.headless=true", \
    "-Dspring.profiles.active=qa", \
    "-jar", "/admintool.jar"]