Git Product home page Git Product logo

docker-graalvm-maven's Introduction

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 CE native-image feature.

It is automatically built twice per week to include the latest updates and security fixes.

The image comes pre-installed with latest releases of:

Further we add the user user with uid 1000 and gid 1000 as non-privileged user in order to run without root privileges. Note, that the user is not set to 1000 within the docker image. Specify the uid to be 1000 with your docker run command.

Docker image tagging scheme

Tag Description
:latest-java11
:latest-java17
:latest-java21
:latest-java22
latest available GraalVM CE releases for the given JDK
:dev-java23 latest available GraalVM CE development builds for the given JDK
:XX.Y.Z the given GraalVM CE releases (e.g. 17.0.8 for JDK 17 and 21.0.0 for JDK 21) following GraaLVM's new version naming scheme.
:XX.Y.Z-java11
:XX.Y.Z-java17
the given GraalVM CE releases (e.g. 22.3.2-java11) following GraaLVM's old version naming scheme

See all available tags at https://hub.docker.com/r/vegardit/graalvm-maven/tags

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 \
      vegardit/graalvm-maven: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 ^
      vegardit/graalvm-maven: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 \
      vegardit/graalvm-maven: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 \
  vegardit/graalvm-maven: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 \
      vegardit/graalvm-maven: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/.

docker-graalvm-maven's People

Contributors

dependabot[bot] avatar sebthom avatar spike83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

docker-graalvm-maven's Issues

graalvm-maven:latest-java17 not compatible with AWS Runtime

There is a GLibC incompatibility

INIT_START Runtime Version: provided:al2.v20	Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:e448fca582d6ef7f5f1faf3cae4b2bb6521010ebae50e60019812234a4c0d549
./runner: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./runner)
./runner: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./runner)

graalvm-maven:22.3.2-java17 is OK

Support for new GraalVM Release

Hi,
First of all thanks a lot for this awesome image. Such a time saver piece of work and we are actively using it in our native builds.
As you may know, in the last week, the team released the newest version of the GraalVM. Is there any plan to support it in the pipeline? Or should we solve this out by ourselves?
A New GraalVM Release and New Free License!
Cheers,
Korkut.

"ld returned 1 exit status" when building native Quarkus project

Building vanilla Quarkus project https://quarkus.io/ fails with the following error:

...
[3/7] Building universe...                                                                               (9.7s @ 2.30GB)
[4/7] Parsing methods...      [******]                                                                  (43.7s @ 2.24GB)
[5/7] Inlining methods...     [*****]                                                                   (31.8s @ 2.83GB)
[6/7] Compiling methods...    [*************]                                                          (185.0s @ 4.01GB)
[7/7] Creating image...                                                                                  (0.0s @ 3.31GB)
Fatal error: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1
Based on the linker command output, possible reasons for this include:
1. It appears as though libstdc++.a is missing. Please install it.
Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-6638468409718322790/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /mnt/space/work/default/target/core-1.0.0-SNAPSHOT-native-image-source-jar/core-1.0.0-SNAPSHOT-runner core-1.0.0-SNAPSHOT-runner.o /opt/graalvm/lib/svm/clibraries/linux-amd64/liblibchelper.a /opt/graalvm/lib/static/linux-amd64/glibc/libnet.a /opt/graalvm/lib/static/linux-amd64/glibc/libextnet.a /opt/graalvm/lib/static/linux-amd64/glibc/libnio.a /opt/graalvm/lib/static/linux-amd64/glibc/libmanagement_ext.a /opt/graalvm/lib/static/linux-amd64/glibc/libjava.a /opt/graalvm/lib/static/linux-amd64/glibc/libfdlibm.a /opt/graalvm/lib/static/linux-amd64/glibc/libsunec.a /opt/graalvm/lib/static/linux-amd64/glibc/libzip.a /opt/graalvm/lib/svm/clibraries/linux-amd64/libjvm.a -v -L/tmp/SVM-6638468409718322790 -L/opt/graalvm/lib/static/linux-amd64/glibc -L/opt/graalvm/lib/svm/clibraries/linux-amd64 -lstdc++ -lpthread -ldl -lz -lrt -no-pie
Linker command output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-o' '/mnt/space/work/default/target/core-1.0.0-SNAPSHOT-native-image-source-jar/core-1.0.0-SNAPSHOT-runner' '-v' '-L/tmp/SVM-6638468409718322790' '-L/opt/graalvm/lib/static/linux-amd64/glibc' '-L/opt/graalvm/lib/svm/clibraries/linux-amd64' '-no-pie' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/10/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper -plugin-opt=-fresolution=/tmp/ccnI24fI.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /mnt/space/work/default/target/core-1.0.0-SNAPSHOT-native-image-source-jar/core-1.0.0-SNAPSHOT-runner -z noexecstack /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/10/crtbegin.o -L/tmp/SVM-6638468409718322790 -L/opt/graalvm/lib/static/linux-amd64/glibc -L/opt/graalvm/lib/svm/clibraries/linux-amd64 -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/10/../../.. --gc-sections --dynamic-list /tmp/SVM-6638468409718322790/exported_symbols.list --exclude-libs ALL -x core-1.0.0-SNAPSHOT-runner.o /opt/graalvm/lib/svm/clibraries/linux-amd64/liblibchelper.a /opt/graalvm/lib/static/linux-amd64/glibc/libnet.a /opt/graalvm/lib/static/linux-amd64/glibc/libextnet.a /opt/graalvm/lib/static/linux-amd64/glibc/libnio.a /opt/graalvm/lib/static/linux-amd64/glibc/libmanagement_ext.a /opt/graalvm/lib/static/linux-amd64/glibc/libjava.a /opt/graalvm/lib/static/linux-amd64/glibc/libfdlibm.a /opt/graalvm/lib/static/linux-amd64/glibc/libsunec.a /opt/graalvm/lib/static/linux-amd64/glibc/libzip.a /opt/graalvm/lib/svm/clibraries/linux-amd64/libjvm.a -lstdc++ -lpthread -ldl -lz -lrt -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/10/crtend.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status
	at com.oracle.svm.hosted.image.NativeImageViaCC.handleLinkerFailure(NativeImageViaCC.java:505)
	at com.oracle.svm.hosted.image.NativeImageViaCC.write(NativeImageViaCC.java:452)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:695)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:515)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:407)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)
------------------------------------------------------------------------------------------------------------------------
                       56.6s (11.6% of total time) in 102 GCs | Peak RSS: 5.45GB | CPU load: 1.93
=========================================================================================
Failed generating 'core-1.0.0-SNAPSHOT-runner' after 8m 6s.
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Probably compatibility issue with most recent GraalVM. Is it possible for you to tag your Docker image releases with GraalVM version?

Support for Java 22

Hello team,

This is my first ticket.
I have been using this project for long, really, just thank you.

Java 22 is around the corner.
Could you please support java 22 as well?

Thank you

Charset utf-8 not working when use vegardit/graalvm-maven:latest-java11 from docker

I use vegardit/graalvm-maven:latest-java11 in docker to run service read data from mysql

my url connection: jdbc:mysql://{myip:myport}/{mydatabase}?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false

raw data: Tập đoàn T&T Group hợp tác chiến lược toàn diện với Tập đoàn VNPT
read data: T?p ?o?n T&T Group h?p t?c chi?n l??c to?n di?n v?i T?p ?o?n VNPT

When i use maven:3.6.3-jdk-11 everything is fine

Image built with this graalvm maven got openssl-3.0.2, which has vulnerabilities.

Hello team,

I am using this image to build containers.
The container works fine, this image is great.

Unfortunately, we have daily scans of images built with these images.
All images are being flagged using openssl-3.0.2, which has many vulnerabilities.

May I ask if it is possible to bump openssl to a safe version?
Thank you

The JAVA_HOME environment variable is not defined correctly

[root@localhost DataCenter]# docker run --rm -it \

-v $PWD:/mnt/myproject:rw
-w /mnt/myproject
vegardit/graalvm-maven:latest-java17
mvn clean package

The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.

Support for Java 21

Hello,

This is my first post in this repo, if not anything else, big thanks for this project.

I have been using the vegardit/graalvm-maven:22.3.2-java17 for a while now, very happy, many thanks.

With Java 21 Ga, production ready, GraalVM team is also getting ready.

May I ask if this project can help support java 21 as well? Some kind of vegardit/graalvm-maven:X-java21

Thank you for your time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.