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).
Execute the below command using Gradle from the project directory:
./gradlew bootBuildImage./mvnw -Pnative spring-boot:build-imageAfter 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-SNAPSHOTTo 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).
Execute the below command using Gradle from the project directory:
./mvnw -Pnative native:compile./gradlew nativeCompileYou 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-calendarTo test the application, open a web browser and navigate to:
http://localhost:8080

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.

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:
To gracefully shut down the application, press Ctrl + C.

