Java 8 image in docker file

70 Views Asked by At

I have written a docker file, to config jenkins, node, npm and awscli. I want to add java 8 to this docker file, so that i can use java version 8 inside Jenkins. Below is my dockerfile

FROM jenkins/jenkins
    
USER root
    
    
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
        apt-get install -y nodejs
    
    
RUN curl -L https://www.npmjs.com/install.sh | sh
    
    
RUN apt-get update && apt-get install -y awscli
    
    
RUN npm install -g serverless
    
USER jenkins

I tried adding various images but none of them seems to be working, or it is deprecated

What can I add to add java 8 here.

1

There are 1 best solutions below

0
datawookie On

The Jenkins image already has a version of Java installed. We'll install Java 8 as well and set up the path for the jenkins user to use it. I'm not sure what impact this will have on the functionality of Jenkins, but it does what you have asked.

Dockerfile

FROM jenkins/jenkins
    
USER root
    
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
    apt-get install -y nodejs && \
    curl -L https://www.npmjs.com/install.sh | sh && \
    apt-get update && apt-get install -y awscli && \
    npm install -g serverless

RUN curl -s -L -O "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u402-b06/OpenJDK8U-jdk_x64_linux_hotspot_8u402b06.tar.gz" && \
    tar -zxf OpenJDK8U-jdk_x64_linux_hotspot_8u402b06.tar.gz -C /opt/java/

USER jenkins

ENV JAVA_HOME="/opt/java/jdk8u402-b06/"
ENV PATH="$JAVA_HOME/bin:${PATH}"

OpenJDK version 1.8.0 indicates Java 8.

enter image description here