Skip to content

Latest commit

 

History

History
83 lines (48 loc) · 2.69 KB

File metadata and controls

83 lines (48 loc) · 2.69 KB

chapter19.03-calendar

Prerequisites for Buildpacks

Ensure Docker is installed by referring to the details in the Docker documentation (Get Docker | Docker Docs). If you are using Linux, configure Docker to permit non-root users. For macOS users, it is advisable to enhance the allocated Docker memory to a minimum of 8 GB and consider adding more CPUs. On Microsoft Windows, ensure optimal performance by enabling the Docker WSL 2 backend (Docker Desktop WSL 2 backend on Windows | Docker Docs).

Building GraalVM images using Buildpacks and Gradle

Execute the below command using Gradle from the project directory:

./gradlew bootBuildImage

Building GraalVM images using Buildpacks and Maven

./mvnw -Pnative spring-boot:build-image

Running GraalVM images from Buildpacks

After executing the relevant build command for Maven or Gradle, a Docker image should be accessible.

Initiate your application by utilizing the docker run command:

docker run --rm -p 8080:8080 docker.io/library/chapter19.03-calendar:0.0.1-SNAPSHOT

Prerequisites for Native Build Tools

To generate a native image with the Native Build Tools, ensure that you have a GraalVM distribution installed on your system. For our examples, we will use bellsoft-liberica-vm-openjdk17-23.0.3 that is available in the Liberica Native Image Kit Download Center (Download Liberica Native Image Kit, NIK 23 (JDK 17).

Building GraalVM images using Native Build Tools and Maven

Execute the below command using Gradle from the project directory:

./mvnw -Pnative native:compile

Building GraalVM images using Native Build Tools and Gradle

./gradlew nativeCompile

Running GraalVM images with Native Build Tools

You can locate the native image executable within the directory named build/native/nativeCompile if using gradle. Or target directory if using Maven

For Maven for example, you can run the application by executing it directly:

target/chapter19.03-calendar

Testing the application

To test the application, open a web browser and navigate to: http://localhost:8080 img.png

Sign in to the application with admin1@example.com/admin1 or user1@example.com/user1and try accessing: http://localhost:8080/events. You will notice all the events can be displayed. img.png

When you sign in to the application with user1@example.com/user1 and try accessing: http://localhost:8080/events, You will get the following access denied page:

img.pngimg.png

To gracefully shut down the application, press Ctrl + C.