-
Notifications
You must be signed in to change notification settings - Fork 209
[AURON #2024] Support multi-JDK versions in Docker images. #2025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
slfan1989
wants to merge
1
commit into
apache:master
Choose a base branch
from
slfan1989:auron-2024
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -62,22 +62,51 @@ RUN curl https://sh.rustup.rs -sSf -o rustup-init && \ | |
| ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
|
||
| # --------------------------------------------------------------------- | ||
| # Install Java (Microsoft OpenJDK 17 - matches Azure Synapse Spark pools) | ||
| # --------------------------------------------------------------------- | ||
| RUN tdnf -y install msopenjdk-17 && \ | ||
| tdnf clean all && \ | ||
| rm -rf /var/cache/tdnf | ||
|
|
||
| # Set JAVA_HOME for Microsoft OpenJDK 17 on Azure Linux | ||
| ENV JAVA_HOME="/usr/lib/jvm/msopenjdk-17" | ||
| # Install Java (multiple Temurin OpenJDK versions) | ||
| # NOTE: JDK 8 and JDK 11 are EOL. Prefer JDK 17+ for new usage. | ||
| # --------------------------------------------------------------------- | ||
| ARG JDK_VERSIONS="8 11 17 21" | ||
| ARG DEFAULT_JDK="8" | ||
| ENV JAVA_INSTALL_BASE="/opt/java" | ||
| RUN set -eux; \ | ||
| mkdir -p "${JAVA_INSTALL_BASE}"; \ | ||
| for v in ${JDK_VERSIONS}; do \ | ||
| url="https://github.com/adoptium/temurin${v}-binaries/releases/latest/download/OpenJDK${v}U-jdk_x64_linux_hotspot.tar.gz"; \ | ||
| curl -fsSL "$url" -o /tmp/temurin.tar.gz || { echo "Failed to download JDK ${v}"; exit 1; }; \ | ||
| mkdir -p "${JAVA_INSTALL_BASE}/temurin-${v}"; \ | ||
| tar -xzf /tmp/temurin.tar.gz -C "${JAVA_INSTALL_BASE}/temurin-${v}" --strip-components=1; \ | ||
| done; \ | ||
| rm -f /tmp/temurin.tar.gz; \ | ||
| alt="$(command -v update-alternatives || command -v alternatives)"; \ | ||
| for v in ${JDK_VERSIONS}; do \ | ||
| "$alt" --install /usr/bin/java java "${JAVA_INSTALL_BASE}/temurin-${v}/bin/java" $((100 + v)); \ | ||
| "$alt" --install /usr/bin/javac javac "${JAVA_INSTALL_BASE}/temurin-${v}/bin/javac" $((100 + v)); \ | ||
| done; \ | ||
| "$alt" --set java "${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}/bin/java"; \ | ||
| "$alt" --set javac "${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}/bin/javac" | ||
|
Comment on lines
+69
to
+86
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This patterns seems like it would bloat the base image quite a bit. Why not, either
|
||
| # Default JAVA_HOME is set at build time; run `source /etc/profile.d/java.sh` after set-java to update. | ||
| ENV JAVA_HOME="${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}" | ||
| ENV PATH="${JAVA_HOME}/bin:${PATH}" | ||
|
|
||
| # --------------------------------------------------------------------- | ||
| # Create .bashrc with necessary environment variables | ||
| # --------------------------------------------------------------------- | ||
| RUN echo 'export PATH="/root/.cargo/bin:${PATH}"' > /root/.bashrc && \ | ||
| echo 'export JAVA_HOME="/usr/lib/jvm/msopenjdk-17"' >> /root/.bashrc && \ | ||
| echo 'export PATH="${JAVA_HOME}/bin:${PATH}"' >> /root/.bashrc | ||
| # Helper to switch JDK at runtime (e.g., set-java 11) | ||
| RUN printf '%s\n' \ | ||
| '#!/usr/bin/env bash' \ | ||
| 'set -euo pipefail' \ | ||
| 'ver="${1:-}"' \ | ||
| 'if [ -z "$ver" ]; then echo "usage: set-java <version>"; exit 2; fi' \ | ||
| 'base="/opt/java/temurin-${ver}"' \ | ||
| 'if [ ! -x "${base}/bin/java" ]; then echo "JDK ${ver} not installed"; exit 1; fi' \ | ||
| 'alt="$(command -v update-alternatives || command -v alternatives)"' \ | ||
| '"$alt" --set java "${base}/bin/java"' \ | ||
| '"$alt" --set javac "${base}/bin/javac"' \ | ||
| 'echo "Java switched to version ${ver}. Run '\''source /etc/profile.d/java.sh'\'' to update JAVA_HOME."' \ | ||
| > /usr/local/bin/set-java && chmod +x /usr/local/bin/set-java | ||
|
|
||
| # Dynamic JAVA_HOME for interactive shells | ||
| RUN printf '%s\n' \ | ||
| 'export JAVA_HOME="$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")"' \ | ||
| 'export PATH="${JAVA_HOME}/bin:${PATH}"' \ | ||
| > /etc/profile.d/java.sh | ||
|
|
||
| # --------------------------------------------------------------------- | ||
| # Set working directory | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -58,14 +58,52 @@ RUN curl https://sh.rustup.rs -sSf -o rustup-init && \ | |
| ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
|
||
| # --------------------------------------------------------------------- | ||
| # Install Java (OpenJDK 11) | ||
| # --------------------------------------------------------------------- | ||
| RUN apt-get update -y && \ | ||
| apt-get install -y --no-install-recommends openjdk-11-jdk && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
| ENV JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" | ||
| # Install Java (multiple Temurin OpenJDK versions) | ||
| # NOTE: JDK 8 and JDK 11 are EOL. Prefer JDK 17+ for new usage. | ||
| # --------------------------------------------------------------------- | ||
| ARG JDK_VERSIONS="8 11 17 21" | ||
| ARG DEFAULT_JDK="8" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why the default is still JDK 8? |
||
| ENV JAVA_INSTALL_BASE="/opt/java" | ||
| RUN set -eux; \ | ||
| mkdir -p "${JAVA_INSTALL_BASE}"; \ | ||
| for v in ${JDK_VERSIONS}; do \ | ||
| url="https://github.com/adoptium/temurin${v}-binaries/releases/latest/download/OpenJDK${v}U-jdk_x64_linux_hotspot.tar.gz"; \ | ||
| curl -fsSL "$url" -o /tmp/temurin.tar.gz || { echo "Failed to download JDK ${v}"; exit 1; }; \ | ||
| mkdir -p "${JAVA_INSTALL_BASE}/temurin-${v}"; \ | ||
| tar -xzf /tmp/temurin.tar.gz -C "${JAVA_INSTALL_BASE}/temurin-${v}" --strip-components=1; \ | ||
| done; \ | ||
| rm -f /tmp/temurin.tar.gz; \ | ||
| alt="$(command -v update-alternatives || command -v alternatives)"; \ | ||
| for v in ${JDK_VERSIONS}; do \ | ||
| "$alt" --install /usr/bin/java java "${JAVA_INSTALL_BASE}/temurin-${v}/bin/java" $((100 + v)); \ | ||
| "$alt" --install /usr/bin/javac javac "${JAVA_INSTALL_BASE}/temurin-${v}/bin/javac" $((100 + v)); \ | ||
| done; \ | ||
| "$alt" --set java "${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}/bin/java"; \ | ||
| "$alt" --set javac "${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}/bin/javac" | ||
| # Default JAVA_HOME is set at build time; run `source /etc/profile.d/java.sh` after set-java to update. | ||
| ENV JAVA_HOME="${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}" | ||
| ENV PATH="${JAVA_HOME}/bin:${PATH}" | ||
|
|
||
| # Helper to switch JDK at runtime (e.g., set-java 11) | ||
| RUN printf '%s\n' \ | ||
| '#!/usr/bin/env bash' \ | ||
| 'set -euo pipefail' \ | ||
| 'ver="${1:-}"' \ | ||
| 'if [ -z "$ver" ]; then echo "usage: set-java <version>"; exit 2; fi' \ | ||
| 'base="/opt/java/temurin-${ver}"' \ | ||
| 'if [ ! -x "${base}/bin/java" ]; then echo "JDK ${ver} not installed"; exit 1; fi' \ | ||
| 'alt="$(command -v update-alternatives || command -v alternatives)"' \ | ||
| '"$alt" --set java "${base}/bin/java"' \ | ||
| '"$alt" --set javac "${base}/bin/javac"' \ | ||
| 'echo "Java switched to version ${ver}. Run '\''source /etc/profile.d/java.sh'\'' to update JAVA_HOME."' \ | ||
| > /usr/local/bin/set-java && chmod +x /usr/local/bin/set-java | ||
|
|
||
| # Dynamic JAVA_HOME for interactive shells | ||
| RUN printf '%s\n' \ | ||
| 'export JAVA_HOME="$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")"' \ | ||
| 'export PATH="${JAVA_HOME}/bin:${PATH}"' \ | ||
| > /etc/profile.d/java.sh | ||
|
|
||
| # --------------------------------------------------------------------- | ||
| # Set working directory | ||
| # --------------------------------------------------------------------- | ||
|
|
@@ -74,4 +112,4 @@ WORKDIR /auron | |
| # --------------------------------------------------------------------- | ||
| # Default command | ||
| # --------------------------------------------------------------------- | ||
| CMD ["/bin/bash"] | ||
| CMD ["/bin/bash"] | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would still want to install Microsoft OpenJDK based java versions for azurelinux, right?