Skip to content

Instantly share code, notes, and snippets.

@ecliptik
Last active August 18, 2020 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecliptik/4da4f68e67fcc311f27c490e135b1ffa to your computer and use it in GitHub Desktop.
Save ecliptik/4da4f68e67fcc311f27c490e135b1ffa to your computer and use it in GitHub Desktop.
jenv inside Docker container image
#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