slug | id | type | title | tabs | difficulty | timelimit | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
quarkus-containerization |
nibc44rlcujp |
challenge |
Topic 4 - Containerise the Quarkus App using Podman |
|
intermediate |
300 |
With the help of podman, we will containerize the quarkus application so that it becomes more portable and ready to be deployed on Podman / Kubernetes (OpenShift).
For that, we need to first create an image of it. Before creating a container image, we need to run one maven command which creates all the dependency files we want while creating the image.
cd quarkus-crud-mssql/
./mvnw package
This Dockerfile is used to build a container that runs the Quarkus application in JVM mode. You can also build in native,native-micro, and legacy-jar as per your requirement.
Quarkus provide us with multiple Dockerfiles with their location of it:
├── mvnw
├── mvnw.cmd
├── pom.xml
├── README.md
├── src
│ ├── main
│ │ ├── docker
│ │ │ ├── Dockerfile.jvm
│ │ │ ├── Dockerfile.legacy-jar
│ │ │ ├── Dockerfile.native
│ │ │ └── Dockerfile.native-micro
To build a podman image, you have to run the following command.
Now build the container image with help of podman
podman build -f src/main/docker/Dockerfile.jvm -t quarkus/quarks-crud-app .
Now run the container with help of podman run command on port 8080. We are taking the help of the host network for that add --network=host link.
podman run -it -p 8080:8080 --network=host quarkus/quarks-crud-app
As we tested all the API above we have to test it again after containerization like GET. POST, PUT, and DELETE.
Open Terminal 2
GET:
http :8080/person
POST:
http POST :8080/person firstName=Carlos lastName=Santana salutation=Mr
PUT:
http PUT :8080/person/1 firstName=Jimi lastName=Hendrix
DELETE:
http DELETE :8080/person/1
Using Quarkus dramatically reduces the lines of code you have to write. As you have seen, creating a simple REST CRUD service is just a piece of cake. If you then want to move your app to Kubernetes, it’s just a matter of adding another extension to the build process.
Thanks to the Dev Services, you’re even able to do fast prototyping without worrying to install 3rd party apps like databases.
Minimizing the amount of boilerplate code makes your app easier to maintain – and lets you focus on what you have to do implementing the business case.
This is why I fell in love with Quarkus.
Congratulations on completing this lab. Keep learning about OpenShift:
- Visit the Red Hat Developer learning page for more labs and resources
- Want to try a free, instant 30-day OpenShift cluster? Get started with the Developer Sandbox for Red Hat OpenShift
Don't forget to finish the lab and rate your experience on the next page. Thanks for playing!