TEXT   31

Dockerfile openjdk

Guest on 14th May 2022 08:47:25 AM

  1. #
  2. # NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
  3. #
  4. # PLEASE DO NOT EDIT IT DIRECTLY.
  5. #
  6.  
  7. FROM buildpack-deps:sid-scm
  8.  
  9. # A few reasons for installing distribution-provided OpenJDK:
  10. #
  11. #  1. Oracle.  Licensing prevents us from redistributing the official JDK.
  12. #
  13. #  2. Compiling OpenJDK also requires the JDK to be installed, and it gets
  14. #     really hairy.
  15. #
  16. #     For some sample build times, see Debian's buildd logs:
  17. #       https://buildd.debian.org/status/logs.php?pkg=openjdk-9
  18.  
  19. RUN apt-get update && apt-get install -y --no-install-recommends \
  20.                 bzip2 \
  21.                 unzip \
  22.                 xz-utils \
  23.         && rm -rf /var/lib/apt/lists/*
  24.  
  25. # Default to UTF-8 file.encoding
  26. ENV LANG C.UTF-8
  27.  
  28. # add a simple script that can auto-detect the appropriate JAVA_HOME value
  29. # based on whether the JDK or only the JRE is installed
  30. RUN { \
  31.                 echo '#!/bin/sh'; \
  32.                 echo 'set -e'; \
  33.                 echo; \
  34.                 echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
  35.         } > /usr/local/bin/docker-java-home \
  36.         && chmod +x /usr/local/bin/docker-java-home
  37.  
  38. # do some fancy footwork to create a JAVA_HOME that's cross-architecture-safe
  39. RUN ln -svT "/usr/lib/jvm/java-9-openjdk-$(dpkg --print-architecture)" /docker-java-home
  40. ENV JAVA_HOME /docker-java-home
  41.  
  42. ENV JAVA_VERSION 9.0.1+11
  43. ENV JAVA_DEBIAN_VERSION 9.0.1+11-1
  44.  
  45. RUN set -ex; \
  46.         \
  47. # deal with slim variants not having man page directories (which causes "update-alternatives" to fail)
  48.         if [ ! -d /usr/share/man/man1 ]; then \
  49.                 mkdir -p /usr/share/man/man1; \
  50.         fi; \
  51.         \
  52.         apt-get update; \
  53.         apt-get install -y \
  54.                 openjdk-9-jdk="$JAVA_DEBIAN_VERSION" \
  55.         ; \
  56.         rm -rf /var/lib/apt/lists/*; \
  57.         \
  58. # verify that "docker-java-home" returns what we expect
  59.         [ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \
  60.         \
  61. # update-alternatives so that future installs of other OpenJDK versions don't change /usr/bin/java
  62.         update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; \
  63. # ... and verify that it actually worked for one of the alternatives we care about
  64.         update-alternatives --query java | grep -q 'Status: manual'
  65.  
  66. # https://docs.oracle.com/javase/9/tools/jshell.htm
  67. # https://en.wikipedia.org/wiki/JShell
  68. CMD ["jshell"]
  69.  
  70. # If you're reading this and have any feedback on how this image could be
  71. # improved, please open an issue or a pull request so we can discuss it!
  72. #
  73. #   https://github.com/docker-library/openjdk/issues

Raw Paste


Login or Register to edit or fork this paste. It's free.