This project uses Quarkus, the Supersonic Subatomic Java Framework.
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
You can run your application in dev mode that enables live coding using:
./mvnw compile quarkus:dev
NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
The application can be packaged using:
./mvnw package
It produces the quarkus-run.jar
file in the target/quarkus-app/
directory.
Be aware that it’s not an über-jar as the dependencies are copied into the target/quarkus-app/lib/
directory.
The application is now runnable using java -jar target/quarkus-app/quarkus-run.jar
.
If you want to build an über-jar, execute the following command:
./mvnw package -Dquarkus.package.type=uber-jar
The application, packaged as an über-jar, is now runnable using java -jar target/*-runner.jar
.
Manually create the database for local testing (with initialization file) ...
podman run -d --name pg-library-shop -p 5432:5432 \
-e POSTGRES_USER=quarkus -e POSTGRES_PASSWORD=quarkus -e POSTGRES_DATABASE=quarkus \
-v $PWD/src/main/database:/docker-entrypoint-initdb.d:ro,z \
docker.io/library/postgres:17
You can create a native executable using:
./mvnw package -Dnative
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
./mvnw package -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=podman
You can then execute your native executable with: ./target/library-shop-1.0.0-runner
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
To create the container image review the file Containerfile.jvm
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.21-1
ENV LANGUAGE='en_US:en'
# We make four distinct layers so if there are application changes the library-shop layers can be re-used
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
Execute the command :
podman build -f ./src/main/docker/Containerfile.jvm -t rha/library-shop:1.0.0 .
Using jib (quarkus-container-image-jib) extension
./mvnw package -Pjib
Check the iamge
podman run --rm -it -e DATABASE_HOST=alumno -p 8080:8080 rha/library-shop-jib:1.0.0
Using docker (quarkus-container-image-docker) extension
./mvnw package -Pdocker
Check the iamge
podman run --rm -it -e DATABASE_HOST=alumno -p 8080:8080 rha/library-shop-docker:1.0.0
FROM registry.access.redhat.com/ubi9/ubi-micro:9.5-1733126338
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application
EXPOSE 8080
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Launch an application build
mvn package oc:build -DskipTests -Djkube.docker.verbose
Launch the deploy
mvn package oc:resource oc:apply -DskipTests
Launch a rollout
mvn oc:rollout
Check the application OpenAPI specification
http://localhost:8080/q/swagger-ui
Create a book
curl -i -X POST http://localhost:8080/library -H "Content-type: application/json" -d '{"title":"The Difference Engine","year":1990,"isbn":"0-575-04762-3","price":12.0,"authors":[{"name":"William Gibson"},{"name":"Bruce Sterling"}]}'
Get a book by Id
curl -s http://localhost:8080/library/1 | jq
Update the book price
curl -i -X PUT http://localhost:8080/library/1/price\?price\=15.00
Paged list all the books
curl -s http://localhost:8080/library/ | jq
- REST resources for Hibernate ORM with Panache (guide): Generate Jakarta REST resources for your Hibernate Panache entities and repositories
- SmallRye OpenAPI (guide): Document your REST APIs with OpenAPI - comes with Swagger UI
- REST Jackson (guide): Jackson serialization support for Quarkus REST. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it
- SmallRye Health (guide): Monitor service health
- JDBC Driver - PostgreSQL (guide): Connect to the PostgreSQL database via JDBC
Generating Jakarta REST resources with Panache
Easily start your REST Web Services
Monitor your application's health using SmallRye Health