diff --git a/core/java8/Dockerfile b/core/java8/Dockerfile index abc0112f..05efa6e1 100644 --- a/core/java8/Dockerfile +++ b/core/java8/Dockerfile @@ -37,4 +37,6 @@ RUN cd /javaAction \ && rm -rf /javaAction/src \ && ./compileClassCache.sh -CMD ["java", "-Dfile.encoding=UTF-8", "-Xshareclasses:cacheDir=/javaSharedCache,readonly", "-Xquickstart", "-jar", "/javaAction/build/libs/javaAction-all.jar"] +ADD init.sh ./ +RUN chmod 777 ./init.sh +CMD ["./init.sh"] \ No newline at end of file diff --git a/core/java8/init.sh b/core/java8/init.sh new file mode 100644 index 00000000..28a2a8c3 --- /dev/null +++ b/core/java8/init.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +limit_in_bytes=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) +heap_size=64 +export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xshareclasses:cacheDir=/javaSharedCache,readonly -Xquickstart" +export RESERVED_MEGABYTES=64 + +# If not default limit_in_bytes in cgroup +if [ "$limit_in_bytes" -ne "9223372036854771712" ] +then + limit_in_megabytes=$(expr $limit_in_bytes \/ 1048576) + heap_size=$(expr $limit_in_megabytes - $RESERVED_MEGABYTES) + export JAVA_OPTS="-Xmx${heap_size}m $JAVA_OPTS" +fi + +echo JAVA_OPTS= $JAVA_OPTS + +java $JAVA_OPTS -jar /javaAction/build/libs/javaAction-all.jar