Sunny Chan blogs Can you see the Logic in my Madness?

Centos Docker images for building OpenJDK

by schan


Posted on Saturday Nov 01, 2014 at 03:43PM in Java


I am going to lead an OpenJDK hackathon in Taiwan later this month and I am trying to create an VM image so that people can get up and running quickly. Then last couple of weeks I came across Docker, which is a very simple container which allows easy deployment of images to your machine. So I have decided to try and see whether I can create some docker images for Hackathon use. Here is what I have come up with:


https://registry.hub.docker.com/u/sunnythepooh/openjdk-build


There are two images, one build with Centos 6 base image and one with Centos 7. Out of the container there are all the dependency you need to build OpenJDK 9, and an openjdk user. Once you pull the image down, you can login as openjdk and use mercurial to download openjdk and build straight away.


For Linux, you can install docker directly on any modern distribution. On Windows/MacOS you can use Boot2docker which would give you a very small Linux VM which you can run docker command from and you can take a look at the following command sequence to compile a OpenJDK 9 build:


[schan@sandybridge ~]$ sudo docker run -t -i sunnythepooh/openjdk-build:centos6 /bin/bash
bash-4.2# login openjdk
Password:
Last login: Fri Oct 31 05:02:55 on pts/1
-bash: cannot set terminal process group (-1): Inappropriate ioctl for device
-bash: no job control in this shell
[openjdk@e583ed8a4e04 ~]$ hg clone http://hg.openjdk.java.net/jdk9/dev jdk9
requesting all changes
adding changesets
adding manifests
adding file changes
added 1213 changesets with 1750 changes to 151 files
updating to branch default
93 files updated, 0 files merged, 0 files removed, 0 files unresolved
[openjdk@e583ed8a4e04 ~]$ cd jdk9
[openjdk@e583ed8a4e04 jdk9]$ ls
ASSEMBLY_EXCEPTION Makefile README-builds.html common get_source.sh modules.xml
LICENSE README THIRD_PARTY_README configure make test
[openjdk@e583ed8a4e04 jdk9]$ bash get_source.sh
WARNING: Mercurial version 2.6.3 or later is recommended. /bin/hg is version 2.6.2
# Repositories: corba jaxp jaxws langtools jdk hotspot nashorn
corba: hg clone http://hg.openjdk.java.net/jdk9/dev/corba corba
jaxp: hg clone http://hg.openjdk.java.net/jdk9/dev/jaxp jaxp
corba: requesting all changes
.............................................................................cut for brevity..........................................................................
nashorn: searching for changes
nashorn: no changes found
jdk: searching for changes
jdk: no changes found
jaxws: searching for changes
jaxws: no changes found
jaxp: searching for changes
jaxp: no changes found
.: searching for changes
hotspot: searching for changes
.: no changes found
hotspot: no changes found
corba: searching for changes
corba: no changes found
langtools: searching for changes
langtools: no changes found
[openjdk@e583ed8a4e04 jdk9]$ bash ./configure
Running generated-configure.sh
configure: Configuration created at Sat Nov 1 05:15:04 GMT 2014.
configure: configure script generated at timestamp 1414663067.
checking for basename... /bin/basename
checking for bash... /bin/bash
checking for cat... /bin/cat
checking for chmod... /bin/chmod
checking for cmp... /bin/cmp
checking for comm... /bin/comm
checking for cp... /bin/cp
checking for cut... /bin/cut
checking for date... /bin/date
.............................................................................cut for brevity..........................................................................
====================================================
A new configuration has been successfully created in
/home/openjdk/jdk9/build/linux-x86_64-normal-server-release
using default settings.

Configuration summary:
* Debug level: release
* HS debug level: product
* JDK variant: normal
* JVM variants: server
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64

Tools summary:
* Boot JDK: openjdk version "1.8.0-internal" OpenJDK Runtime Environment (build 1.8.0-internal-openjdk_2014_10_31_05_05-b00) OpenJDK 64-Bit Server VM (build 25.20-b23, mixed mode) (at /usr/local/jvm/openjdk-1.8.0-internal)
* Toolchain: gcc (GNU Compiler Collection)
* C Compiler: Version 4.8.2 (at /bin/gcc)
* C++ Compiler: Version 4.8.2 (at /bin/g++)

Build performance summary:
* Cores to use: 7
* Memory limit: 11753 MB

WARNING: Your build output directory is not on a local disk.
This will severely degrade build performance!
It is recommended that you create an output directory on a local disk,
and run the configure script again from that directory.
[openjdk@e583ed8a4e04 jdk9]$ make images
Running make as '/bin/gmake -s VERBOSE=-s LOG_LEVEL=warn -R -I /home/openjdk/jdk9/make/common -s SPEC=/home/openjdk/jdk9//build/linux-x86_64-normal-server-release/spec.gmk'
Building OpenJDK for target 'images' in configuration 'linux-x86_64-normal-server-release'
.............................................................................cut for brevity..........................................................................
## Finished verify-modules (build time 00:00:08)

----- Build times -------
Start 2014-11-01 05:23:08
End 2014-11-01 05:30:34
00:00:08 verify-modules
00:07:26 TOTAL
-------------------------

Finished building OpenJDK for target 'images'
[openjdk@e583ed8a4e04 jdk9]$ build/linux-x86_64-normal-server-release/images/j2sdk-image/bin/java -version
openjdk version "1.9.0-internal"
OpenJDK Runtime Environment (build 1.9.0-internal-openjdk_2014_11_01_05_15-b00)
OpenJDK 64-Bit Server VM (build 1.9.0-internal-openjdk_2014_11_01_05_15-b00, mixed mode)



No one has commented yet.

Leave a Comment

HTML Syntax: Allowed