Repo2docker: Add support for Java

Created on 7 Sep 2019  路  6Comments  路  Source: jupyterhub/repo2docker

Proposed change

_Add support for installing Java and Java build tools._

Relevant package managers:

  • Maven triggered by pom.xml
  • Ant triggered by build.xml
  • Gradle triggered by gradle.build

What the BuildPack would do is

  • install Java (anything speaking against always installing the JDK?), matching the version configured in the configuration file

    • Java 8, 11, 12, and 13 are available from default sources, which seems enough options

$ docker run --rm -it buildpack-deps:bionic apt-get update && apt-cache search openjdk | grep Kit
[..]                                                  
Fetched 17.1 MB in 15s (1115 kB/s)                                                                                                            
Reading package lists... Done
default-jdk - Standard Java or Java compatible Development Kit
default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
default-jdk-headless - Standard Java or Java compatible Development Kit (headless)
openjdk-11-doc - OpenJDK Development Kit (JDK) documentation
openjdk-11-jdk - OpenJDK Development Kit (JDK)
openjdk-11-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-11-source - OpenJDK Development Kit (JDK) source files
openjdk-12-doc - OpenJDK Development Kit (JDK) documentation
openjdk-12-jdk - OpenJDK Development Kit (JDK)
openjdk-12-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-12-source - OpenJDK Development Kit (JDK) source files
openjdk-13-doc - OpenJDK Development Kit (JDK) documentation
openjdk-13-jdk - OpenJDK Development Kit (JDK)
openjdk-13-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-13-source - OpenJDK Development Kit (JDK) source files
openjdk-8-doc - OpenJDK Development Kit (JDK) documentation
openjdk-8-jdk - OpenJDK Development Kit (JDK)
openjdk-8-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-8-source - OpenJDK Development Kit (JDK) source files
  • install the build tool
  • run the build tool (Is there a need or a good way to define the used options?)

Alternative options

Users would have to install Java and build tools/project managers manually, e.g. using postBuild.

Who would use this feature?

Java users.

How much effort will adding it take?

Depending on how many build tools are supported (could of course be added later) I guess 2 days of work. A good part of that would be to create different project configurations for tests.

Who can do this work?

Somebody familiar with BuildPacks and Java, and the different Java build tools.

enhancement help wanted discussion

Most helpful comment

I might have a good reason to try this out early next year, just adding a few notes. There are options to run Java from Jupyter Notebooks, one of which should be included by default.

IJava already somehow supports Binder! https://mybinder.org/v2/gh/SpencerPark/ijava-binder/master?urlpath=lab/tree/home/jovyan/3rdPartyDependency.ipynb > https://github.com/SpencerPark/ijava-binder has a custom Dockerfile.

Pinging @SpencerPark - have you thought about adding Java support natively in repo2docker? Just want to make sure I'm not missing any big obstacles here.

All 6 comments

I might have a good reason to try this out early next year, just adding a few notes. There are options to run Java from Jupyter Notebooks, one of which should be included by default.

IJava already somehow supports Binder! https://mybinder.org/v2/gh/SpencerPark/ijava-binder/master?urlpath=lab/tree/home/jovyan/3rdPartyDependency.ipynb > https://github.com/SpencerPark/ijava-binder has a custom Dockerfile.

Pinging @SpencerPark - have you thought about adding Java support natively in repo2docker? Just want to make sure I'm not missing any big obstacles here.

The official kernel list also lists most of the above projects: https://github.com/jupyter/jupyter/wiki/Jupyter-kernels

Just wanted to upvote this idea! @nuest @SpencerPark

Do you want to give implementing this a try @melaniewalsh ?

Hi all, I'm happy to help out where I can but have little experience with Docker. Had to use docker classroom to build the dockerfile used in the ijava-binder :p The Dockerfile over there is super simple, the base layer (forgive my docker terminology) is some stable jdk which is itself based on some linux layer (I think ubuntu). So it just installs python and jupyter on top of that and runs the ijava install.

The docs look a bit different than the last time I visited but https://mybinder.readthedocs.io/en/latest/sample_repos.html#minimal-dockerfiles-for-binder contains everything I based the Docker file on.

IJava is intentionally light on the dependencies for an easy install, just jupyter (and the transitive dep, python) and a jdk. The default kernel.json picks up java from the $PATH, jshell is distributed with the jdk and the rest of the libs are packaged with the kernel so the only system dep is the jdk.

So a few naive questions:

  1. What is a buildpack?
  2. What does "adding it natively in repo2docker" mean? Specifically for users either creating, extending, or consuming, repos?

A build pack is a class in repo2docker that does two things. 1) it has a method that when pointed at a directory can decide if this build pack should be applied and 2) a method that generates statements that should be added in the Dockerfile repo2docker generates. In more detail: https://repo2docker.readthedocs.io/en/latest/architecture.html#buildpacks

"adding it natively" means that as a user I wouldn't have to write a Dockerfile any more. Placing for example a pom.xml at the root of my repository would be enough to trigger the installation of the jdk, ijava and packages listed in the pom.xml file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

minrk picture minrk  路  6Comments

sje30 picture sje30  路  3Comments

choldgraf picture choldgraf  路  4Comments

consideRatio picture consideRatio  路  6Comments

trallard picture trallard  路  4Comments