- install GraalVM CE
sdk install java 21-graalce
java -version # see 21
native-image --version # see 21
- mvn build
mvn clean package && java -jar ./target/jibber-0.0.1-SNAPSHOT-exec.jar &
- test
curl http://localhost:8080/jibber
- kill process
fg # bring to foreground then Ctrl-C
-
build docker image
docker build -f ./00-containerise/Dockerfile \ --build-arg JAR_FILE=./target/jibber-0.0.1-SNAPSHOT-exec.jar \ -t localhost/jibber:java.01 .
-
Query Docker to look at your newly built image:
docker images | head -n2 && docker images localhost/jibber:java.01
-
Run this image as follows:
docker run --rm -d --name "jibber-java" -p 8080:8080 localhost/jibber:java.01
-
Test
curl http://localhost:8080/jibber
-
check log
docker logs jibber-java
-
terminate container
docker kill jibber-java
- mvn build
mvn package -Pnative # take ~10min
# or use spring boot plugin
mvn -Pnative native:compile
- check and run
ls -lh target/jibber;
./target/jibber &
- test
curl http://localhost:8080/jibber
- terminate process
fg # bring to foreground then Ctrl-C
- build docker image
docker build -f ./01-native-image/Dockerfile \
--build-arg APP_FILE=./target/jibber \
-t localhost/jibber:native.01 .
- Take a look at the newly built image:
docker images | head -n2 && docker images localhost/jibber:native.01
- run docker image
docker run --rm -d --name "jibber-native" -p 8080:8080 localhost/jibber:native.01
- test
curl http://localhost:8080/jibber
- check log
docker logs jibber-native
- terminate the running docker
docker kill jibber-native
gradle clean build && gradle bootRun;
gradle nativeCompile && build/native/nativeCompile/graalvm21lab;
# build docker native image, not yet working, wait for java 21
gradle bootBuildImage;
- how to clean docker cache:
docker builder prune