Skip to content

Commit

Permalink
Merge pull request #247 from rhuss/master
Browse files Browse the repository at this point in the history
Updating dependencies and run-java.sh
  • Loading branch information
rhuss committed Apr 29, 2020
2 parents c67d2a0 + 526cdb3 commit 9d1a9bf
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 25 deletions.
2 changes: 1 addition & 1 deletion java/fish-pepper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ blocks:
- type: "git"
url: "https://github.com/fabric8io-images/run-java-sh.git"
path: "fish-pepper"
tag: "v1.3.2"
tag: "v1.3.7"
2 changes: 1 addition & 1 deletion java/images/centos-java11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The startup process is configured mostly via environment variables:
* **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides.
* **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**.
* **JAVA_OPTIONS** options to add when calling `java`
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits.
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output.
* **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added.
* **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set.
* **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed.
Expand Down
33 changes: 29 additions & 4 deletions java/images/centos-java11/run-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# https://www.youtube.com/watch?v=w1rZOY5gbvk
# https://vimeo.com/album/4133413/video/181900266
# Also note that heap is only a small portion of the memory used by a JVM. There are lot
# of other memory areas (metadata, thread, code cache, ...) which addes to the overall
# of other memory areas (metadata, thread, code cache, ...) which adds to the overall
# size. When your container gets killed because of an OOM, then you should tune
# the absolute values.
# JAVA_INIT_MEM_RATIO: Ratio use to calculate a default intial heap memory, in percent.
Expand Down Expand Up @@ -188,6 +188,23 @@ init_limit_env_vars() {
fi
}

init_java_major_version() {
# Initialize JAVA_MAJOR_VERSION variable if missing
if [ -z "${JAVA_MAJOR_VERSION:-}" ]; then
local full_version=""

# Parse JAVA_VERSION variable available in containers
if [ -n "${JAVA_VERSION:-}" ]; then
full_version="$JAVA_VERSION"
elif [ -n "${JAVA_HOME:-}" ] && [ -r "${JAVA_HOME}/release" ]; then
full_version="$(grep -e '^JAVA_VERSION=' ${JAVA_HOME}/release | sed -e 's/.*\"\([0-9.]\{1,\}\).*/\1/')"
else
full_version=$(java -version 2>&1 | head -1 | sed -e 's/.*\"\([0-9.]\{1,\}\).*/\1/')
fi
export JAVA_MAJOR_VERSION=$(echo $full_version | sed -e 's/\(1\.\)\{0,1\}\([0-9]\{1,\}\).*/\2/')
fi
}

load_env() {
local script_dir="$1"

Expand Down Expand Up @@ -237,14 +254,19 @@ run_java_options() {

debug_options() {
if [ -n "${JAVA_ENABLE_DEBUG:-}" ] || [ -n "${JAVA_DEBUG_ENABLE:-}" ] || [ -n "${JAVA_DEBUG:-}" ]; then
local debug_port="${JAVA_DEBUG_PORT:-5005}"
local debug_port="${JAVA_DEBUG_PORT:-5005}"
local suspend_mode="n"
if [ -n "${JAVA_DEBUG_SUSPEND:-}" ]; then
if ! echo "${JAVA_DEBUG_SUSPEND}" | grep -q -e '^\(false\|n\|no\|0\)$'; then
suspend_mode="y"
fi
fi
echo "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${suspend_mode},address=${debug_port}"

local address_prefix=""
if [ "${JAVA_MAJOR_VERSION:-0}" -ge "9" ]; then
address_prefix="*:"
fi
echo "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${suspend_mode},address=${address_prefix}${debug_port}"
fi
}

Expand Down Expand Up @@ -483,7 +505,7 @@ proxy_options() {

local noProxy="${no_proxy:-${NO_PROXY:-}}"
if [ -n "$noProxy" ] ; then
ret="$ret -Dhttp.nonProxyHosts=\"$(echo "|$noProxy" | sed -e 's/,[[:space:]]*/|/g' | sed -e 's/|\./|\*\./g' | cut -c 2-)\""
ret="$ret -Dhttp.nonProxyHosts=$(echo "|$noProxy" | sed -e 's/,[[:space:]]*/|/g' | sed -e 's/[[:space:]]//g' | sed -e 's/|\./|\*\./g' | cut -c 2-)"
fi
echo "$ret"
}
Expand Down Expand Up @@ -608,6 +630,9 @@ run() {
# =============================================================================
# Fire up

# Initialize JAVA_MAJOR_VERSION variable if missing
init_java_major_version

# Set env vars reflecting limits
init_limit_env_vars

Expand Down
2 changes: 1 addition & 1 deletion java/images/centos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The startup process is configured mostly via environment variables:
* **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides.
* **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**.
* **JAVA_OPTIONS** options to add when calling `java`
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits.
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output.
* **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added.
* **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set.
* **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed.
Expand Down
33 changes: 29 additions & 4 deletions java/images/centos/run-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# https://www.youtube.com/watch?v=w1rZOY5gbvk
# https://vimeo.com/album/4133413/video/181900266
# Also note that heap is only a small portion of the memory used by a JVM. There are lot
# of other memory areas (metadata, thread, code cache, ...) which addes to the overall
# of other memory areas (metadata, thread, code cache, ...) which adds to the overall
# size. When your container gets killed because of an OOM, then you should tune
# the absolute values.
# JAVA_INIT_MEM_RATIO: Ratio use to calculate a default intial heap memory, in percent.
Expand Down Expand Up @@ -188,6 +188,23 @@ init_limit_env_vars() {
fi
}

init_java_major_version() {
# Initialize JAVA_MAJOR_VERSION variable if missing
if [ -z "${JAVA_MAJOR_VERSION:-}" ]; then
local full_version=""

# Parse JAVA_VERSION variable available in containers
if [ -n "${JAVA_VERSION:-}" ]; then
full_version="$JAVA_VERSION"
elif [ -n "${JAVA_HOME:-}" ] && [ -r "${JAVA_HOME}/release" ]; then
full_version="$(grep -e '^JAVA_VERSION=' ${JAVA_HOME}/release | sed -e 's/.*\"\([0-9.]\{1,\}\).*/\1/')"
else
full_version=$(java -version 2>&1 | head -1 | sed -e 's/.*\"\([0-9.]\{1,\}\).*/\1/')
fi
export JAVA_MAJOR_VERSION=$(echo $full_version | sed -e 's/\(1\.\)\{0,1\}\([0-9]\{1,\}\).*/\2/')
fi
}

load_env() {
local script_dir="$1"

Expand Down Expand Up @@ -237,14 +254,19 @@ run_java_options() {

debug_options() {
if [ -n "${JAVA_ENABLE_DEBUG:-}" ] || [ -n "${JAVA_DEBUG_ENABLE:-}" ] || [ -n "${JAVA_DEBUG:-}" ]; then
local debug_port="${JAVA_DEBUG_PORT:-5005}"
local debug_port="${JAVA_DEBUG_PORT:-5005}"
local suspend_mode="n"
if [ -n "${JAVA_DEBUG_SUSPEND:-}" ]; then
if ! echo "${JAVA_DEBUG_SUSPEND}" | grep -q -e '^\(false\|n\|no\|0\)$'; then
suspend_mode="y"
fi
fi
echo "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${suspend_mode},address=${debug_port}"

local address_prefix=""
if [ "${JAVA_MAJOR_VERSION:-0}" -ge "9" ]; then
address_prefix="*:"
fi
echo "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${suspend_mode},address=${address_prefix}${debug_port}"
fi
}

Expand Down Expand Up @@ -483,7 +505,7 @@ proxy_options() {

local noProxy="${no_proxy:-${NO_PROXY:-}}"
if [ -n "$noProxy" ] ; then
ret="$ret -Dhttp.nonProxyHosts=\"$(echo "|$noProxy" | sed -e 's/,[[:space:]]*/|/g' | sed -e 's/|\./|\*\./g' | cut -c 2-)\""
ret="$ret -Dhttp.nonProxyHosts=$(echo "|$noProxy" | sed -e 's/,[[:space:]]*/|/g' | sed -e 's/[[:space:]]//g' | sed -e 's/|\./|\*\./g' | cut -c 2-)"
fi
echo "$ret"
}
Expand Down Expand Up @@ -608,6 +630,9 @@ run() {
# =============================================================================
# Fire up

# Initialize JAVA_MAJOR_VERSION variable if missing
init_java_major_version

# Set env vars reflecting limits
init_limit_env_vars

Expand Down
2 changes: 1 addition & 1 deletion java/images/fedora-java11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The startup process is configured mostly via environment variables:
* **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides.
* **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**.
* **JAVA_OPTIONS** options to add when calling `java`
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits.
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output.
* **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added.
* **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set.
* **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed.
Expand Down
33 changes: 29 additions & 4 deletions java/images/fedora-java11/run-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# https://www.youtube.com/watch?v=w1rZOY5gbvk
# https://vimeo.com/album/4133413/video/181900266
# Also note that heap is only a small portion of the memory used by a JVM. There are lot
# of other memory areas (metadata, thread, code cache, ...) which addes to the overall
# of other memory areas (metadata, thread, code cache, ...) which adds to the overall
# size. When your container gets killed because of an OOM, then you should tune
# the absolute values.
# JAVA_INIT_MEM_RATIO: Ratio use to calculate a default intial heap memory, in percent.
Expand Down Expand Up @@ -188,6 +188,23 @@ init_limit_env_vars() {
fi
}

init_java_major_version() {
# Initialize JAVA_MAJOR_VERSION variable if missing
if [ -z "${JAVA_MAJOR_VERSION:-}" ]; then
local full_version=""

# Parse JAVA_VERSION variable available in containers
if [ -n "${JAVA_VERSION:-}" ]; then
full_version="$JAVA_VERSION"
elif [ -n "${JAVA_HOME:-}" ] && [ -r "${JAVA_HOME}/release" ]; then
full_version="$(grep -e '^JAVA_VERSION=' ${JAVA_HOME}/release | sed -e 's/.*\"\([0-9.]\{1,\}\).*/\1/')"
else
full_version=$(java -version 2>&1 | head -1 | sed -e 's/.*\"\([0-9.]\{1,\}\).*/\1/')
fi
export JAVA_MAJOR_VERSION=$(echo $full_version | sed -e 's/\(1\.\)\{0,1\}\([0-9]\{1,\}\).*/\2/')
fi
}

load_env() {
local script_dir="$1"

Expand Down Expand Up @@ -237,14 +254,19 @@ run_java_options() {

debug_options() {
if [ -n "${JAVA_ENABLE_DEBUG:-}" ] || [ -n "${JAVA_DEBUG_ENABLE:-}" ] || [ -n "${JAVA_DEBUG:-}" ]; then
local debug_port="${JAVA_DEBUG_PORT:-5005}"
local debug_port="${JAVA_DEBUG_PORT:-5005}"
local suspend_mode="n"
if [ -n "${JAVA_DEBUG_SUSPEND:-}" ]; then
if ! echo "${JAVA_DEBUG_SUSPEND}" | grep -q -e '^\(false\|n\|no\|0\)$'; then
suspend_mode="y"
fi
fi
echo "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${suspend_mode},address=${debug_port}"

local address_prefix=""
if [ "${JAVA_MAJOR_VERSION:-0}" -ge "9" ]; then
address_prefix="*:"
fi
echo "-agentlib:jdwp=transport=dt_socket,server=y,suspend=${suspend_mode},address=${address_prefix}${debug_port}"
fi
}

Expand Down Expand Up @@ -483,7 +505,7 @@ proxy_options() {

local noProxy="${no_proxy:-${NO_PROXY:-}}"
if [ -n "$noProxy" ] ; then
ret="$ret -Dhttp.nonProxyHosts=\"$(echo "|$noProxy" | sed -e 's/,[[:space:]]*/|/g' | sed -e 's/|\./|\*\./g' | cut -c 2-)\""
ret="$ret -Dhttp.nonProxyHosts=$(echo "|$noProxy" | sed -e 's/,[[:space:]]*/|/g' | sed -e 's/[[:space:]]//g' | sed -e 's/|\./|\*\./g' | cut -c 2-)"
fi
echo "$ret"
}
Expand Down Expand Up @@ -608,6 +630,9 @@ run() {
# =============================================================================
# Fire up

# Initialize JAVA_MAJOR_VERSION variable if missing
init_java_major_version

# Set env vars reflecting limits
init_limit_env_vars

Expand Down
2 changes: 1 addition & 1 deletion java/images/rhel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The startup process is configured mostly via environment variables:
* **JAVA_APP_DIR** the directory where the application resides. All paths in your application are relative to this directory. By default it is the same directory where this startup script resides.
* **JAVA_LIB_DIR** directory holding the Java jar files as well an optional `classpath` file which holds the classpath. Either as a single line classpath (colon separated) or with jar files listed line-by-line. If not set **JAVA_LIB_DIR** is the same as **JAVA_APP_DIR**.
* **JAVA_OPTIONS** options to add when calling `java`
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits.
* **JAVA_MAJOR_VERSION** a number >= 7. If the version is set then only options suitable for this version are used. When set to 7 options known only to Java > 8 will be removed. For versions >= 10 no explicit memory limit is calculated since Java >= 10 has support for container limits. If omitted, this parameter's value will be guessed using the `JAVA_VERSION` variable, the `release` file or parsing the `java -version` command output.
* **JAVA_MAX_MEM_RATIO** is used when no `-Xmx` option is given in `JAVA_OPTIONS`. This is used to calculate a default maximal Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio of the container available memory as set here. The default is `25` when the maximum amount of memory available to the container is below 300M, `50` otherwise, which means in that case that 50% of the available memory is used as an upper boundary. You can skip this mechanism by setting this value to 0 in which case no `-Xmx` option is added.
* **JAVA_INIT_MEM_RATIO** is used when no `-Xms` option is given in `JAVA_OPTIONS`. This is used to calculate a default initial Heap Memory based on a containers restriction. If used in a Docker container without any memory constraints for the container then this option has no effect. If there is a memory constraint then `-Xms` is set to a ratio of the container available memory as set here. By default this value is not set.
* **JAVA_MAX_CORE** restrict manually the number of cores available which is used for calculating certain defaults like the number of garbage collector threads. If set to 0 no base JVM tuning based on the number of cores is performed.
Expand Down
Loading

0 comments on commit 9d1a9bf

Please sign in to comment.