FROMdocker.jintdev.com/containers/alpine:3.12# A few reasons for installing distribution-provided OpenJDK:## 1. Oracle. Licensing prevents us from redistributing the official JDK.## 2. Compiling OpenJDK also requires the JDK to be installed, and it gets# really hairy.## For some sample build times, see Debian's buildd logs:# https://buildd.debian.org/status/logs.php?pkg=openjdk-8# Default to UTF-8 file.encodingENVLANG C.UTF-8# add a simple script that can auto-detect the appropriate JAVA_HOME value# based on whether the JDK or only the JRE is installedRUN{ \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-homeENVJAVA_HOME /usr/lib/jvm/java-11-openjdkENVPATH $PATH:/usr/lib/jvm/java-11-openjdk/jre/bin:/usr/lib/jvm/java-11-openjdk/binENVJAVA_VERSION 11u7ENVJAVA_ALPINE_VERSION 11.0.7_p10-r1RUNset -x \
&& apk add --no-cache \
openjdk11-jdk="$JAVA_ALPINE_VERSION" tini curl \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ] \
&& curl -L https://maven.aliyun.com/repository/public/io/prometheus/jmx/jmx_prometheus_javaagent/0.13.0/jmx_prometheus_javaagent-0.13.0.jar > /jmx_prometheus_javaagent-0.13.0.jar \
&& echo ''>/etc/jmx_config.yamlCOPYdocker-entrypoint.sh /ENTRYPOINT["/sbin/tini", "--", "/docker-entrypoint.sh"]# If you're reading this and have any feedback on how this image could be# improved, please open an issue or a pull request so we can discuss it!## https://github.com/docker-library/openjdk/issues#!/bin/bashset-eo pipefailshopt-s nullglobjava_tool_env(){ localexporterPort=11111 if[ $JMX_EXPORTER_PORT ]; then exporterPort=$JMX_EXPORTER_PORT
fi
localexporterConfig=/etc/jmx_config.yaml if[ $JMX_EXPORTER_CONFIG ]; then exporterConfig=$JMX_EXPORTER_CONFIG
fi
exportJAVA_TOOL_OPTIONS="-javaagent:/jmx_prometheus_javaagent-0.13.0.jar=${exporterPort}:${exporterConfig}"
}
[-z $DISABLE_JMX_EXPORTER ] && java_tool_env# 若执行 java, 移除 CMD /bin/sh -c 前缀if[[ "$1" =~ sh$ ]] && [[ "$2" = "-c" ]] && [[ "$3" = "java" ]]; then exec"$BASH_SOURCE" "${@:3}"
fi
# 若CMD以 jar 或 war 文件开始,则直接调用java传入默认参数if[[ "$1" =~ \.jar$|\.war$ ]]; then set-- java -Dsun.misc.URLClassPath.disableJarChecking=true -Djava.security.egd=file:/dev/./urandom $JAVA_OPTS -jar "$@"
fi
# Spring bootif[[ "$1" = "org.springframework.boot.loader.JarLauncher" ]]; then set-- java -Djava.security.egd=file:/dev/./urandom $JAVA_OPTS "$@"
fi
exec"$@"