0

In Windows 10 environment, with IntelliJ Idea, I have a sample Spring Boot application created with bootify, called Bootifytwo, which is located in the C:\CODIGO\IDEA_PROJECTS\bootifytwo folder.

In the pom.xml of said application I have the following dependency configured:

<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
</plugin>

My intention is, using GraalVM, to get to generate the bootifytwo.exe and be able to run it correctly.

To do this, I have downloaded the following Docker image with GraalVM from the Oracle repositories; and performed the following commands:

docker pull container-registry.oracle.com/graalvm/community:ol8-java17-22.3.0-b1

docker images

docker run -it --rm container-registry.oracle.com/graalvm/community:ol8-java17-22.3.0-b1 bash

java -version

gu install native-image

native-image --version

Everything is working fine until I try to change to my project folder.

terminal screenshot

As long as I can´t change to my project folder (cd C:\CODIGO\IDEA_PROJECTS\bootifytwo) I can't create the .exe with the following:

.\mvnw native:compile -Pnative

And finally locate myself in the target folder (cd C:\CODIGO\IDEA_PROJECTS\bootifytwo\target) and launch the desired bootifytwo.exe

I would appreciate help in this complex path. (I don't know if I need to define the GRAALVM_HOME variable, or map a volume...)

JLLMNCHR
  • 1,551
  • 5
  • 24
  • 50
  • It seems `native-image` is not included in this docker image, does `gu install native-image` help? – peterz Dec 22 '22 at 09:03
  • Yo are right. Now I am able to launch 'native-image --version'. – JLLMNCHR Dec 22 '22 at 09:43
  • I edited original post to better reflect actual situation – JLLMNCHR Dec 22 '22 at 09:54
  • You're now inside a Docker image, which has its own filesystem separate from the host filesystem. Plus it's a Linux image, so you should be using Linux paths (`/home/user/` etc). Or you might want to skip the Docker thing altogether, just install a Windows GraalVM package, run `gu install native-image` and build your app right on the host system – peterz Dec 22 '22 at 11:00
  • Previously I tried this way of directly installing GraalVM for Windows. I was able to generate the .exe but when I ran it it failed. That's why I'm trying this second way with Docker. – JLLMNCHR Dec 22 '22 at 11:17
  • On the other hand cd /CODIGO/IDEA_PROJECTS/bootifytwo also failed. I think you might need to map something to the host-docker filesystem... set a volume – JLLMNCHR Dec 22 '22 at 11:19

1 Answers1

0

The solution to generate the .exe was:

Copy the app folder to (future) volume destination:

In my case: C:\CODIGO\IDEA_PROJECTS\bootifytwo to C:\Volumenes-Docker\vol-graalvm-one\bootifytwo

Then launch the following commands:

docker run --name container-graalvm-one -v "C:\Volumenes-Docker\vol-graalvm-one:/app" -it container-registry.oracle.com/graalvm/community:ol8-java17-22.3.0-b1 bash

gu install native-image

cd bootifytwo

. ./mvnw native:compile -Pnative

successful build

not an exe file

Then, I was able to launch the app with:

./bootifytwo

But fails in the connection with my DB (that also was "inside" another docker/postgres container)

enter image description here

JLLMNCHR
  • 1,551
  • 5
  • 24
  • 50