JavaFx Maven Docker Image

Recently when setting up a Jenkins build environment to use a Docker Image with Maven that could build a JavaFX project.  Thanks to some searching and a bit of hunting I was able to create a Docker image to perform just what I needed: OpenJDK, OpenJFX(JavaFX), and Maven. I wanted the DockerFile to be a part of my project so that if changes were necessary down the road I could make them in Git and my build environment would pick them up.

  1. I began by creating a docker directory in my maven project.  This gives me the ability to modify the Dockerfile as needed for my project.
  2. Next, you need to download the official package of files for Maven.  I choose to use the maven:jdk-8 as my base image. When you download this Dockerfile, do not make the mistake I did and miss the mvn-entrypoint.sh and settings-docker.xml files you will need these.  Place all three files in your docker directory.
  3. Now you need to modify the Dockerfile to include in OpenJFX on top OpenJDK in the environment. Add the lines I have highlighted below:
  4. Next, since you put these files in a subdirectory you need to make another slight change:
  5. For completeness I will include the code for the other two files here as well:


     

With this, you now have a Dockerfile that supports JavaFX compilations in Maven.

2 thoughts on “JavaFx Maven Docker Image

  • November 22, 2017 at 7:42 am
    Permalink

    This does not really work for me.
    I have a docker jenkins image where I want to add javaxfx support.

    But adding the code as mentioned by “OpenJFX on top OpenJDK” results into the following when building the docker image. The very base image is
    FROM jenkins/jenkins:lts
    which is
    FROM openjdk:8-jdk

    here is what happens:

    $> sudo docker build -t greyshine/jenkins_jfx .
    Sending build context to Docker daemon 695.8kB
    Step 1/14 : FROM jenkins/jenkins:lts
    —> e6b6a36fca5a
    Step 2/14 : RUN apt-get update && apt-get install –no-install-recommends -y openjfx unzip && rm -f /var/lib/apt/lists/*_dists_*
    —> Running in 9f4ed98e2b91
    Reading package lists…
    E: List directory /var/lib/apt/lists/partial is missing. – Acquire (13: Permission denied)
    The command ‘/bin/sh -c apt-get update && apt-get install –no-install-recommends -y openjfx unzip && rm -f /var/lib/apt/lists/*_dists_*’ returned a non-zero code: 100

  • Pingback: JavaFX links of the week, April 24 | JavaFX News, Demos and Insight // FX Experience

Leave a Reply

Your email address will not be published. Required fields are marked *