I am using spring-boot-maven-plugin to build a docker image from my app with this command:
spring-boot::build-image
And I need to change default size of jvm direct memory (default is 10m) with this jvm argument:
-XX:MaxDirectMemorySize=64M
and this is my desperate attempt to do that in pom.xml of app where I was trying everything what came to my mind:
<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <configuration>
                            <jvmArguments>-XX:MaxDirectMemorySize=64M</jvmArguments>
                            <environmentVariables>
                                <JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
                                <JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
                            </environmentVariables>
                            <systemPropertyVariables>
                                <JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
                                <JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <layers>
                        <enabled>true</enabled>
                    </layers>
                    <image>
                        <name>docker.io/example/${project.artifactId}:${project.version}</name>
                    </image>
                    <excludeDevtools>true</excludeDevtools>
                    <systemPropertyVariables>
                        <JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
                        <JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
                    </systemPropertyVariables>
                    <environmentVariables>
                        <JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
                        <JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
                    </environmentVariables>
                    <jvmArguments>-XX:MaxDirectMemorySize=64M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</jvmArguments>
                </configuration>
            </plugin>
But direct memory is still setup to 10M :( which I can see in log file when the app is booting up:
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -agentpath:/layers/paketo-buildpacks_bellsoft-liberica/jvmkill/jvmkill-1.16.0-RELEASE.so=printHeapHistogram=1 -XX:ActiveProcessorCount=8 -XX:MaxDirectMemorySize=10M -Xmx11521920K -XX:MaxMetaspaceSize=144375K -XX:ReservedCodeCacheSize=240M -Xss1M -Dorg.springframework.cloud.bindings.boot.enable=true
Can anybody advise me what Am I doing wrong?
NOTES:
Spring Boot: 2.3.7.RELEASE
when I run docker image manually with -e, change of jvm argument is working:
docker run -e JAVA_TOOL_OPTIONS=-XX:MaxDirectMemorySize=64M  docker.io/example/app-name:0.0.1
this mvn plugin is using Buildpack to create the docker image:
https://paketo.io/docs/buildpacks/language-family-buildpacks/java/#about-the-jvm
UPDATE:
by the doc this should be working solution but it is not:
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <layers>
                        <enabled>true</enabled>
                    </layers>
                    <image>
                        <name>docker.io/example/${project.artifactId}:${project.version}</name>
                        <env>
                            <JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
                        </env>
                    </image>
                </configuration>