Skip to content

Latest commit

 

History

History
115 lines (83 loc) · 4.75 KB

File metadata and controls

115 lines (83 loc) · 4.75 KB

docker-graalvm-maven

Build Status License Docker Pulls Docker Stars Contributor Covenant

  1. What is it?
  2. Usage
  3. License

What is it?

Opinionated docker image based on the Debian docker image debian:stable-slim to build native Linux binaries from Java Maven projects using GraalVM native-image feature.

It is automatically built daily to include the latest updates and security fixes.

The image comes pre-installed with latest releases of:

Usage

Building a local Maven project

To build a Maven project located on your local workstation with via this docker image you can do:

  1. On Linux:

    $ cd ~/myproject
    $ docker run --rm -it \
      -v $PWD:/mnt/myproject:rw \
      -w /mnt/myproject \
      wiradikusuma/graalvm-maven-for-quarkus:latest-java17 \
      mvn clean package
  2. On Windows:

    C:> cd C:\Users\MyUser\myproject
    C:\Users\MyUser\myproject> docker run --rm -it ^
      -v /c/Users/MyUser/myproject:/mnt/myproject:rw ^
      -w /mnt/myproject ^
      wiradikusuma/graalvm-maven-for-quarkus:latest-java17 ^
      mvn clean package

Also checkout the example project which provides convenient batch/bash script wrappers and outlines how to do compile Java projects to native Linux binaries.

Using custom Maven settings.xml

You can use a custom Maven settings.xml by mounting it to /root/.m2/settings.xml

    $ cd ~/myproject
    $ docker run --rm -it \
      -v /path/to/my/settings.xml:/root/.m2/settings.xml:ro \
      -v $PWD:/mnt/myproject:rw \
      -w /mnt/myproject \
      wiradikusuma/graalvm-maven-for-quarkus:latest-java17 \
      mvn clean package

Running docker commands inside the container

This image has the docker command line client installed, which allows you to run other docker containers as part of your build toolchain using a docker-out-of-docker (DooD) approach by mounting the /var/run/docker.sock into the container.

$ cd ~/myproject
$ docker run --rm -it \
  -v /var/run/docker.sock:/var/run/docker.sock:rw \
  -v $PWD:/mnt/myproject:rw \
  wiradikusuma/graalvm-maven-for-quarkus:latest-java17 \
  docker run --rm hello-world

Caching local Maven repository between runs

You can a local folder to /root/.m2/repository to cache the downloaded artifacts between Maven runs

    $ cd ~/myproject
    $ docker run --rm -it \
      -v /path/to/my/local/repository:/root/.m2/repository:rw \
      -v $PWD:/mnt/myproject:rw \
      -w /mnt/myproject \
      wiradikusuma/graalvm-maven-for-quarkus:latest-java17 \
      mvn clean package

License

All files in this repository are released under the Apache License 2.0.

Individual files contain the following tag instead of the full license text:

SPDX-License-Identifier: Apache-2.0

This enables machine processing of license information based on the SPDX License Identifiers that are available here: https://spdx.org/licenses/.