Last active
August 18, 2020 00:10
-
-
Save ecliptik/4da4f68e67fcc311f27c490e135b1ffa to your computer and use it in GitHub Desktop.
jenv inside Docker container image
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
#Build and run with a specific version of java within the build image | |
#eg Java 11: docker build --build-arg JAVA_VERSION=11 -t jenv . | |
#eg Java 8: docker build --build-arg JAVA_VERSION=1.8 -t jenv . | |
FROM debian:buster | |
RUN apt update && apt install -y ca-certificates wget | |
RUN wget -O- https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz | tar -xz -C /opt/ | |
RUN wget -O- https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u265-b01/OpenJDK8U-jdk_x64_linux_hotspot_8u265b01.tar.gz | tar -xz -C /opt/ | |
RUN wget -O- https://github.com/jenv/jenv/archive/0.5.3.tar.gz | tar -xz -C /opt/ | |
ENV PATH="/root/.jenv/shims:/opt/jenv-0.5.3/bin:$PATH" | |
RUN mkdir -p /root/.jenv/versions/ && echo 'eval "$(jenv init -)"' >> /etc/bash.bashrc | |
RUN jenv add /opt/jdk-11.0.8+10 | |
RUN jenv add /opt/jdk8u265-b01 | |
ARG JAVA_VERSION= | |
ENV JAVA_VERSION=${JAVA_VERSION} | |
RUN jenv global ${JAVA_VERSION} | |
RUN java -version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment