Skip to content

Latest commit

 

History

History
157 lines (79 loc) · 3.56 KB

File metadata and controls

157 lines (79 loc) · 3.56 KB
slug id type title tabs difficulty timelimit
quarkus-containerization
nibc44rlcujp
challenge
Topic 4 - Containerise the Quarkus App using Podman
title type hostname
Terminal 1
terminal
rhel
title type hostname
Terminal 2
terminal
rhel
intermediate
300

4. Containerize the Quarkus App using Podman

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.

4.1. building dockerfile

Now build the container image with help of podman

podman build -f src/main/docker/Dockerfile.jvm -t quarkus/quarks-crud-app .

4.2. Run Quarkus container

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

Summary

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.

What's Next?

Congratulations on completing this lab. Keep learning about OpenShift:

Don't forget to finish the lab and rate your experience on the next page. Thanks for playing!