FROM docker.jintdev.com/containers/alpine:edge
# 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.encoding
ENV LANG 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 installed
RUN { \
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-home
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk
ENV PATH $PATH:/usr/lib/jvm/java-17-openjdk/jre/bin:/usr/lib/jvm/java-17-openjdk/bin
ENV JAVA_VERSION 17
ENV JAVA_ALPINE_VERSION 17.0.1_p12-r0
RUN set -x \
&& apk add fontconfig --no-cache \
openjdk17-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.16.1/jmx_prometheus_javaagent-0.16.1.jar > /jmx_prometheus_javaagent-0.16.1.jar \
&& echo ''>/etc/jmx_config.yaml
COPY docker-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/bash
set -eo pipefail
shopt -s nullglob
java_tool_env() {
local exporterPort=11111
if [ $JMX_EXPORTER_PORT ]; then
exporterPort=$JMX_EXPORTER_PORT
fi
local exporterConfig=/etc/jmx_config.yaml
if [ $JMX_EXPORTER_CONFIG ]; then
exporterConfig=$JMX_EXPORTER_CONFIG
fi
export JAVA_TOOL_OPTIONS="-javaagent:/jmx_prometheus_javaagent-0.16.1.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 boot
if [[ "$1" = "org.springframework.boot.loader.JarLauncher" ]]; then
set -- java -Djava.security.egd=file:/dev/./urandom $JAVA_OPTS "$@"
fi
exec "$@"