-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use multistage build dockerfiles for JDK24+
- Loading branch information
Showing
5 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% include 'partials/license.j2' %} | ||
|
||
FROM {{ base_image }} AS build | ||
|
||
{% include 'partials/nix-env.j2' %} | ||
|
||
RUN set -eux; \ | ||
apk add --no-cache \ | ||
# gnupg required to verify the signature | ||
gnupg | ||
|
||
{% include 'partials/java-version.j2' %} | ||
|
||
{% include 'partials/multi-arch-install.j2' %} | ||
|
||
FROM {{ base_image }} | ||
|
||
ENV JAVA_HOME=/opt/java/openjdk | ||
|
||
RUN set -eux; \ | ||
apk add --no-cache \ | ||
# java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory | ||
# java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager | ||
# https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 | ||
fontconfig ttf-dejavu \ | ||
# utilities for keeping Alpine and OpenJDK CA certificates in sync | ||
# https://github.com/adoptium/containers/issues/293 | ||
ca-certificates p11-kit-trust \ | ||
# locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 | ||
musl-locales musl-locales-lang \ | ||
{%- include 'partials/binutils.j2' %} | ||
tzdata \ | ||
# Contains `csplit` used for splitting multiple certificates in one file to multiple files, since keytool can | ||
# only import one at a time. | ||
coreutils \ | ||
# Needed to extract CN and generate aliases for certificates | ||
openssl \ | ||
; \ | ||
rm -rf /var/cache/apk/* | ||
|
||
{% include 'partials/java-version.j2' %} | ||
|
||
COPY --from=build $JAVA_HOME $JAVA_HOME | ||
|
||
{% include 'partials/version-check.j2' %} | ||
{% include 'partials/entrypoint.j2' %} | ||
{% include 'partials/jshell.j2' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% include 'partials/license.j2' %} | ||
|
||
FROM {{ base_image }} AS build | ||
|
||
ENV JAVA_HOME=/opt/java/openjdk | ||
|
||
RUN set -eux; \ | ||
microdnf install -y \ | ||
gzip \ | ||
tar \ | ||
wget | ||
|
||
{% include 'partials/multi-arch-install.j2' %} | ||
|
||
FROM {{ base_image }} | ||
|
||
{% include 'partials/nix-env.j2' %} | ||
|
||
RUN set -eux; \ | ||
microdnf install -y \ | ||
# Required for jlink | ||
binutils \ | ||
tzdata \ | ||
# utilities for keeping UBI and OpenJDK CA certificates in sync | ||
# https://github.com/adoptium/containers/issues/293 | ||
ca-certificates \ | ||
# java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory | ||
# java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager | ||
# https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 | ||
fontconfig \ | ||
glibc-langpack-en \ | ||
; \ | ||
microdnf clean all | ||
|
||
{% include 'partials/java-version.j2' %} | ||
|
||
COPY --from=build $JAVA_HOME $JAVA_HOME | ||
|
||
{% include 'partials/version-check.j2' %} | ||
{% include 'partials/entrypoint.j2' %} | ||
{% include 'partials/jshell.j2' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{% include 'partials/license.j2' %} | ||
|
||
FROM {{ base_image }} AS build | ||
|
||
ENV JAVA_HOME=/opt/java/openjdk | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
# required for SSL certificate checking | ||
ca-certificates \ | ||
# gnupg required to verify the signature | ||
gnupg \ | ||
wget | ||
|
||
{% include 'partials/multi-arch-install.j2' %} | ||
|
||
FROM {{ base_image }} | ||
|
||
{% include 'partials/nix-env.j2' %} | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
# java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory | ||
# java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager | ||
# https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077 | ||
fontconfig \ | ||
# utilities for keeping Ubuntu and OpenJDK CA certificates in sync | ||
# https://github.com/adoptium/containers/issues/293 | ||
ca-certificates p11-kit \ | ||
{%- include 'partials/binutils.j2' %} | ||
tzdata \ | ||
# locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8 | ||
locales \ | ||
; \ | ||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ | ||
locale-gen en_US.UTF-8; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
{% include 'partials/java-version.j2' %} | ||
|
||
COPY --from=build $JAVA_HOME $JAVA_HOME | ||
|
||
RUN set -eux; \ | ||
# https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 | ||
find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ | ||
{% if version|int >= 11 -%} | ||
ldconfig; \ | ||
# https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 | ||
# https://openjdk.java.net/jeps/341 | ||
java -Xshare:dump; | ||
{% else -%} | ||
ldconfig; | ||
{% endif %} | ||
{% include 'partials/version-check.j2' %} | ||
{% include 'partials/entrypoint.j2' %} | ||
{% include 'partials/jshell.j2' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters