The purpose of this Github repository is to showcase typical use cases of Quarkus in applications development.
ℹ️ Use SDKMAN! to manage Java and Maven versions
The project is a backend for a book store. It provides a REST API to Create, Read, Update and Delete books, and a REST API to retrieve the ISBN of the book.
The following SmallRye APIs can be found through the project:
The project uses Quarkus as the Java stack, and the built in SmallRye components.
The required infrastructure provided by either Docker or Kubernetes includes:
Set up a local Docker Registry first to store the generated Docker images:
docker run -d -p 5000:5000 --restart=always --name docker-registry registry:2
Use Maven to build the project with the following command from the project root:
mvn verify -Dquarkus.container-image.build=true
The easiest way to run the entire system is to use docker-compose
. This will run the apps, plus all the required
infrastructure. Run the following command from the project root:
docker-compose up
Use the following command to stop and remove all the containers:
docker-compose down
The infrastructure is still required to run the applications properly. They can also be set up manually in the running
host, or use docker-compose
to start only the required infrastructure:
docker-compose up database zookeeper kafka prometheus jaeger
To execute number-api
and book-api
directly, run the following command from each module root:
java -jar target/number-api-runner.jar
java -jar target/book-api-runner.jar
The infrastructure to run in Kubernetes is available in the .kubernetes
folder.
Set the default Kubernetes namespace:
kubectl config set-context --current --namespace=default
To start the infrastructure run:
kubectl apply -f .kubernetes
Quarkus is able to generate the Kubernetes deployment files and deploy the application directly. This requires a Maven build to generate the deployment descriptors:
mvn verify -Dquarkus.container-image.build=true -Dquarkus.kubernetes.deploy=true
Use Swagger-UI to access the applications REST endpoint and invoke the APIs:
For Authentication and Authorization in book-api
you need to call Authorize
in the Swagger interface to generate a
JWT
. Any client_id
, and client_secret
is acceptable.
To check Metris and Tracing information:
Install GraalVM Native Image binary with:
gu install native-image
Set up an environment variable GRAALVM_HOME
pointing to the GraalVM installation folder.
mvn package -Pnative
This is going to generate a binary executable for each module. To execute number-api
and book-api
as native, run
the following command from each module root:
./target/number-api-runner
./target/book-apo-runner
To build Docker Images with the native binaries run the following command:
mvn verify -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true
Or to deploy it directly to Kubernetes:
mvn verify -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true -Dquarkus.kubernetes.deploy=true