Pages

Showing posts with label OpenJDK. Show all posts
Showing posts with label OpenJDK. Show all posts

Thursday, September 27, 2018

"back" to the future Java11: How to create a alpine linux based Docker image with Gradle

This short post is focused on how to build the small docker image based on alpine linux. 
The created image will contain the OpenJDK and Gradle build tool. 
Although you can't download directly the binaries for Alpine from the main page (jdk.java.net/11). You can find the link to download them by using for example google.

To download OpenJdk 11+28 for alpine click here. The binary file uses musl-libc instead of gclib with others.

Let's create a Dockerfile in the older where you have downloaded your OpenJDK binaries.
$ vi Dockerfile 

add following context


FROM alpine:3.8

# source: https://download.java.net/java/early_access/alpine/28/binaries/openjdk-11+28_linux-x64-musl_bin.tar.gz
# variables
ENV JDK_FILE openjdk-11+28_linux-x64-musl_bin.tar.gz
ENV JAVA_HOME /opt/java
ENV GRADLE_VERSION 4.10
ENV GRADLE_HOME /usr/local/gradle-$GRADLE_VERSION
ENV PATH=$GRADLE_HOME/bin:$JAVA_HOME/bin:$PATH

COPY ${JDK_FILE} /tmp
RUN mkdir /opt; cd /opt; \
    tar zxf /tmp/${JDK_FILE} \
    && ln -s jdk-11 java \
    && rm -f /tmp/${JDK_FILE}

RUN java -version

# Donwload and Install Gradle
RUN apk upgrade --update \
&& apk add curl

RUN \
    cd /usr/local && \
    curl -L https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -o gradle-${GRADLE_VERSION}-bin.zip && \
    unzip gradle-${GRADLE_VERSION}-bin.zip && \
    rm gradle-${GRADLE_VERSION}-bin.zip

now we can create and the docker image which does contain Gradle 4.10 and OpenJDK 11+28. For such purposes we do use command:

docker build -f ./Dockerfile -t openjdk11_g4_10 .


after while we can check newly created image by using 
$ docker ps
command

REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
openjdk11_g4_10                                     latest              3e04307e2976        6 hours ago         592MB
to attach sh shell to the container:
docker run -t -i openjdk11_g4_10 /bin/sh 

and we can run the java -version and gradle -version commands.
output:

/ # java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

and 

# gradle -version 
                                                                    
Welcome to Gradle 4.10!

Summary:
The docker container may help you with testing your java application in isolation. You can easily check expected behaviour.  
Happy Coding!

Tuesday, September 18, 2018

OpenJDK, Mission Control: being involved.. coding, coding, coding and more c...

   Almost whole my professional carrier I'm on JVM platforms. It took years of coding and discovering to become familiar and even then there are still many things to be discovered. Simply Java is excited. 
  At some point of time it was not enough to me to be an user of APIs, I wanted to become to be a contributor. I wanted to help with moving the ecosystem forward. 
  The beginning of the journey started by filling out the Java Community Process (JCP) Membership form and then discovering the right project. The JCP form can be found on official web-site
  I've been reading the mailing lists and going through the source code for the while. Aside of it we've started with Marcus Hirt the robo4j project. Due our work on the robo4j project  I felt in love with Java Mission Control . Marcus is really a brilliant project lead. He showed me the beauty of this project and introduced me into its core design structure. He helped me to understand how all parts fit together. Even with his help I had to go through by myself in order to get fully understanding. So I kept pushing on my knowledge.  
  All became to be even more excited after the Oracle Announcement that Java Mission Control is planed be a part of OpenJDK (OpenSourced). At this moment I was allowed to contribute. The story has stared by the documentation, project source code reading, trying to fix opened bugs and discussing.
  This year on September I was promoted to the author role on Java Mission Control project.  
   After my promotion I've received couple questions how to achieve such goal. The short answer is by coding. On the OpenJDK page there is a nice post OpenJDK by Laws, where all is written in more details with roles differences explantation.

   I'm proud to be a part of OpenJDK and I need to give BIG thanks to everyone, especially to my family. Although we have very busy year, my family has found the understanding with hours, I spent by coding.