Closed keeganwitt closed 1 year ago
I originally was going to add GraalVM as a second JVM, but then decided it'd be better to have it be the only JVM (https://github.com/keeganwitt/docker-gradle/compare/5981ff55b9c364bc10a0b5f5cf1c68d3f8319de6..9ad43556146e796ab9cade489c9c0dca9523bbff).
In order for the native image tools to work we need to install the gcc tools:
apt-get install build-essential libz-dev zlib1g-dev
https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites
In order for the native image tools to work we need to install the gcc tools:
apt-get install build-essential libz-dev zlib1g-dev
https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites
Thank you! Added.
Some early feedback I got on the PR is that I should add the packages under build-essential
directly rather than add a dependency on that since that package is meant for building Debian packages. For example, it adds a dependency on dpkg-dev
which installs things that aren't required for this use case.
Folks from Docker Library confirmed that there shouldn't be an issue installing GraalVM even though Graal folks weren't supportive of the idea of making an official image.
This isn't working yet.
* What went wrong:
Gradle could not start your build.
> Could not initialize native services.
> Failed to load native library 'libnative-platform.so' for Linux amd64.
Failed to load native library 'libnative-platform.so' for Linux amd64
It seems to be a folder permission error: https://github.com/gradle/gradle/issues/8107 https://github.com/gradle/gradle/issues/8913
BTW I use the image built by jdk17-graal/Dockerfile
, gradle and native-image programs can work normally.
gradle test:
$ mkdir abc && cd abc
$ gradle init
$ gradle build
$ gradle run
native-image test:
$ javac HelloWorld.java
$ native-image HelloWorld
$ ./helloworld
HelloWorld.java:
public class HelloWorld {
static class Greeter {
static {
System.out.println("Greeter is getting ready!");
}
public static void greet() {
System.out.println("Hello, World!");
}
}
public static void main(String[] args) {
Greeter.greet();
}
}
This isn't working yet.
* What went wrong: Gradle could not start your build. > Could not initialize native services. > Failed to load native library 'libnative-platform.so' for Linux amd64.
Actually, this only happens when not running as root for some reason. docker run --rm -v "${pwd}:/root/project" -w /root/project gradle:17-graal gradle build
FIxed
This isn't working yet.
* What went wrong: Gradle could not start your build. > Could not initialize native services. > Failed to load native library 'libnative-platform.so' for Linux amd64.
Actually, this only happens when not running as root for some reason. docker run --rm -v "${pwd}:/root/project" -w /root/project gradle:17-graal gradle build
Fixed by moving chown
.
BTW I use the image built by
jdk17-graal/Dockerfile
, gradle and native-image programs can work normally.gradle test:
$ mkdir abc && cd abc $ gradle init $ gradle build $ gradle run
native-image test:
$ javac HelloWorld.java $ native-image HelloWorld $ ./helloworld
HelloWorld.java:
public class HelloWorld { static class Greeter { static { System.out.println("Greeter is getting ready!"); } public static void greet() { System.out.println("Hello, World!"); } } public static void main(String[] args) { Greeter.greet(); } }
Thanks for testing this!
Since there are no official images for GraalVM, the only option I can think of for this feature is to install it manually. This unfortunately does mean I'll have to update the images myself whenever there is a new GraalVM release.