diff --git a/.gitignore b/.gitignore index c2a9eca..69e1c29 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,24 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +# Eclipse +.project +.classpath +.settings/ +bin/ + +# IntelliJ +.idea +*.ipr +*.iml +*.iws + +# NetBeans +nb-configuration.xml + +# Visual Studio Code +.vscode +.factorypath + +# OSX .DS_Store \ No newline at end of file diff --git a/docs/.editorconfig b/docs/.editorconfig new file mode 100644 index 0000000..42ae67e --- /dev/null +++ b/docs/.editorconfig @@ -0,0 +1,24 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +[*.{ts, tsx, js, jsx, json, css, scss, yml}] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false +max_line_length = 1024 diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..abd61b0 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,44 @@ +#Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties +.flattened-pom.xml + +# Eclipse +.project +.classpath +.settings/ +bin/ + +# IntelliJ +.idea +*.ipr +*.iml +*.iws + +# NetBeans +nb-configuration.xml + +# Visual Studio Code +.vscode +.factorypath + +# OSX +.DS_Store + +# Vim +*.swp +*.swo + +# patch +*.orig +*.rej + +# Local environment +.env + +# Other +*.dylib + diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..2c83b6a --- /dev/null +++ b/docs/README.md @@ -0,0 +1,9 @@ +# Workshop Documentation + +Convert the AsciiDoc to HTML5 by invoking the `process-resources` goal (configured as the default goal): + +``` +$ mvn +``` + +Open the file _target/generated-docs/index.html_ in your browser to see the generated HTML file. diff --git a/docs/pom.xml b/docs/pom.xml new file mode 100644 index 0000000..d23e8a3 --- /dev/null +++ b/docs/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + io.containerapps.javaruntime.workshop + docs + 1.0.0-SNAPSHOT + Azure Container Apps and Java Runtimes Workshop :: Documentation + + + UTF-8 + 1.8 + 1.8 + 2.2.2 + + + + process-resources + + + org.asciidoctor + asciidoctor-maven-plugin + ${asciidoctor.maven.plugin.version} + + + + + + ${project.version} + + ./images + ./plantuml + ${revision.date} + warn + book + + + + coderay + java + + short + Listing + Appendix + Table + + font + + Figure + + + 3 + left + + 11 + 3.8.x + + + + https://github.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop + https://github.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/issues + https://github.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop.git + + https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/fights-app + + https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/heroes-app + + https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/villains-app + + https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/super-heroes-ui + + + + + asciidoc-to-html + generate-resources + + process-asciidoc + + + html5 + + true + + + - + + + + + + + + diff --git a/docs/src/docs/asciidoc/00-welcome/welcome.adoc b/docs/src/docs/asciidoc/00-welcome/welcome.adoc new file mode 100644 index 0000000..002d490 --- /dev/null +++ b/docs/src/docs/asciidoc/00-welcome/welcome.adoc @@ -0,0 +1,88 @@ +[[welcome]] += Welcome +Let's start from the beginning. +Quarkus. +What's Quarkus? +That's a pretty good question and probably a good start. +If you go to the https://quarkus.io[Quarkus web site], you'll read that Quarkus is "_A Kubernetes Native Java stack tailored for OpenJDK HotSpot & GraalVM, crafted from the best of breed Java libraries and standards_." +This description is somewhat unclear but does an outstanding job at using bankable keywords. +It's also written: "_Supersonic Subatomic Java_." +Still very foggy. +In practice, Quarkus is a stack to develop distributed systems and modern applications in Java, Kotlin, or Scala. +Quarkus applications are tailored for the Cloud, containers, and Kubernetes. +That does not mean you can't use Quarkus in other environments, there are no limits, but the principles infused in Quarkus have made containerization of applications more efficient. +In this workshop, we will explain what Quarkus is and because the best way to understand Quarkus is to use it, build a set of microservices with it. +Again, Quarkus is not limited to microservices, but it's a generally well-understood type of architecture. + +This workshop offers attendees an intro-level, hands-on session with Quarkus, from the first line of code to making services, to consuming them, and finally to assembling everything in a consistent system. +But, what are we going to build? +Well, it's going to be a set of microservices: + +* Using Quarkus +* Using HTTP and events (with Apache Kafka) +* With some parts of the dark side of microservices (resilience, health, monitoring with Prometheus) +* Answer the ultimate question: are super-heroes stronger than super-villains? + +This workshop is a BYOL (_Bring Your Own Laptop_) session, so bring your Windows, OSX, or Linux laptop. +You need JDK {jdk-version} on your machine, Apache Maven ({maven-version}), and Docker. +On Mac and Windows, Docker for _x_ is recommended instead of the Docker toolbox setup. + +What you are going to learn: + +* What is Quarkus, and how you can use it +* How to build an HTTP endpoint (REST API) with Quarkus +* How to access a relational database +* How you can use Swagger and OpenAPI +* How you test your microservice +* How to build a reactive microservice, including reactive data access +* How you improve the resilience of your service +* How to build event-driven microservices with Kafka +* How to build native executable +* How to extend Quarkus with extensions +* And much more! + +Ready? Here we go! + +== Presenting the Workshop + +=== What Is This Workshop About? + +=== What Will You Be Developing? + +[plantuml,align=center,format=png] +---- +include::{plantDir}/welcome-physical-architecture.puml[] +---- + +=== What Will You Be Deploying? + +=== How Does This Workshop Work? + +=== What Do You Have to Do? + +=== Software Requirements + +== Installing Software + +=== VS Code + +== Preparing for the Workshop + +=== Setting Up Azure + +==== Setting Up the Environment Variables + +==== Setting Up the Azure Environment + +==== Creating the Azure Resources + +===== Creating the Container Apps environment + +===== Resource Group + +===== Log Analytics Workspace + +===== Azure Container Registry + +=== Setting Up GitHub + diff --git a/docs/src/docs/asciidoc/01-introduction/introduction.adoc b/docs/src/docs/asciidoc/01-introduction/introduction.adoc new file mode 100644 index 0000000..13050c8 --- /dev/null +++ b/docs/src/docs/asciidoc/01-introduction/introduction.adoc @@ -0,0 +1,10 @@ +[[introduction]] += Introduction + +== What is Azure Container Apps? + +== What is GitHub Actions? + +== What is CodeSpaces and VS Code? + +== What is Quarkus? diff --git a/docs/src/docs/asciidoc/02-quarkus/quarkus.adoc b/docs/src/docs/asciidoc/02-quarkus/quarkus.adoc new file mode 100644 index 0000000..3a3258e --- /dev/null +++ b/docs/src/docs/asciidoc/02-quarkus/quarkus.adoc @@ -0,0 +1,100 @@ +[[quarkus]] += Quarkus + +''' + +At the heart of the Super-Hero application comes Villains! +You can't have superheroes without super-villains. + +We need to expose a REST API allowing CRUD operations on villains. +This microservice is, let's say, a _classical_ REST microservice. +It uses HTTP to expose a REST API and internally store data into a database. +It's using the _imperative_ development model. + +The _fight_ microservice will use this service. + + +In the following sections, you learn: + +* How to create a new Quarkus application +* How to implement REST API using JAX-RS and the RESTEasy Reactive extensionfootnote:[RESTEasy Reactive support the reactive and imperative development models.] +* How to compose your application using beans +* How to access your database using Hibernate ORM with Panache +* How to use transactions +* How to enable OpenAPI and Swagger-UI + +IMPORTANT: This service is exposed on the port 8084. + +But first, let's describe our service. +The Super-Villains microservice manages villains with their names, powers, and so on. +The REST API allows adding, removing, listing, and picking a random villain from the stored set. +Nothing outstanding but a good first step to discover Quarkus. + +[[quarkus-listing-rest-resource]] +.REST Resource +[source,indent=0] +---- +include::{villains-github-raw}/src/main/java/com/azure/containerapps/quarkus/workshop/superheroes/villain/VillainResource.java[] +---- + +== Bootstrapping the Villains Microservice + +=== Directory Structure + +=== The Villain REST Resource + +=== Running the Application + +=== Development Mode + +=== Testing the Application + +== Transactions and ORM + +=== Directory Structure + +=== Installing the PostgreSQL Dependency, Hibernate with Panache and Hibernate Validator + +=== The Villain Entity + +=== Configuring Hibernate + +=== Accessing a database in dev mode + +=== Refactoring the Villain REST Resource + +=== Dependency Injection + +=== Adding Data + +=== Testing the Villain REST Resource + +== Configuring the Villains Microservice + +=== Configuring Logging + +=== Configuring Quarkus Listening Port + +== Open API + +=== Directory Structure + +=== Installing the OpenAPI extension + +=== Default Open API Contract + +=== Customizing the Open API Contract + +==== Customizing Methods + +==== Customizing the Application + +==== Customized Contract + +== Deploying the Villains Microservice + +=== Creating the Managed Postgres Database + +=== Refactoring the CI/CD Pipeline + +=== Deploying the Villains Microservice diff --git a/docs/src/docs/asciidoc/03-micronaut/micronaut.adoc b/docs/src/docs/asciidoc/03-micronaut/micronaut.adoc new file mode 100644 index 0000000..d393798 --- /dev/null +++ b/docs/src/docs/asciidoc/03-micronaut/micronaut.adoc @@ -0,0 +1,74 @@ +[[micronaut]] += Micronaut + +''' + + +[[micronaut-listing-rest-resource]] +.REST Resource +[source,indent=0] +---- +include::{heroes-github-raw}/src/main/java/io/containerapps/quarkus/workshop/superheroes/hero/HeroResource.java[] +---- + +== Bootstrapping the Heroes Microservice + +=== Directory Structure + +=== The Hero REST Resource + +=== Running the Application + +=== Debugging the Application + +=== Testing the Application + +== Transactions and ORM + +=== Directory Structure + +=== Installing the PostgreSQL Dependency, Hibernate with Panache and Hibernate Validator + +=== The Hero Entity + +=== Configuring Hibernate + +=== Accessing a database in dev mode + +=== Refactoring the Hero REST Resource + +=== Dependency Injection + +=== Adding Data + +=== Testing the Hero REST Resource + +== Configuring the Heroes Microservice + +=== Configuring Logging + +=== Configuring Quarkus Listening Port + +== Open API + +=== Directory Structure + +=== Installing the OpenAPI extension + +=== Default Open API Contract + +=== Customizing the Open API Contract + +==== Customizing Methods + +==== Customizing the Application + +==== Customized Contract + +== Deploying the Heroes Microservice + +=== Creating the Managed Postgres Database + +=== Refactoring the CI/CD Pipeline + +=== Deploying the Heroes Microservice diff --git a/docs/src/docs/asciidoc/04-springboot/springboot.adoc b/docs/src/docs/asciidoc/04-springboot/springboot.adoc new file mode 100644 index 0000000..8efa454 --- /dev/null +++ b/docs/src/docs/asciidoc/04-springboot/springboot.adoc @@ -0,0 +1,54 @@ +[[springboot]] += Spring Boot + +''' + + +[[springboot-listing-rest-resource]] +.REST Resource +[source,indent=0] +---- +include::{fights-github-raw}/src/main/java/io/containerapps/quarkus/workshop/superheroes/fight/FightResource.java[] +---- + +== Bootstrapping the Fights Microservice + +=== Directory Structure + +=== The Fight REST Resource + +=== The Fight Entity + +=== Installing the Mongo DB Dependency, Hibernate with Panache and Hibernate Validator + +=== Configuring + +=== Accessing a database in dev mode + +=== Testing the Fight REST Resource + +== Configuring the Fights Microservice + +== Open API + +=== Directory Structure + +=== Installing the OpenAPI extension + +=== Default Open API Contract + +=== Customizing the Open API Contract + +==== Customizing Methods + +==== Customizing the Application + +==== Customized Contract + +== Deploying the Fights Microservice + +=== Creating the Managed Mongo DB Database + +=== Refactoring the CI/CD Pipeline + +=== Deploying the Fights Microservice diff --git a/docs/src/docs/asciidoc/05-scaling/scaling.adoc b/docs/src/docs/asciidoc/05-scaling/scaling.adoc new file mode 100644 index 0000000..9da87b5 --- /dev/null +++ b/docs/src/docs/asciidoc/05-scaling/scaling.adoc @@ -0,0 +1,18 @@ +[[scaling]] += Scaling + +''' + + +[[scaling-listing-rest-resource]] +.REST Resource +[source,indent=0] +---- +include::{fights-github-raw}/src/main/java/io/containerapps/quarkus/workshop/superheroes/fight/FightResource.java[] +---- + +== Load Testing + +== Scaling + + diff --git a/docs/src/docs/asciidoc/images/sunset.jpg b/docs/src/docs/asciidoc/images/sunset.jpg new file mode 100644 index 0000000..48c9129 Binary files /dev/null and b/docs/src/docs/asciidoc/images/sunset.jpg differ diff --git a/docs/src/docs/asciidoc/plantuml/welcome-physical-architecture.puml b/docs/src/docs/asciidoc/plantuml/welcome-physical-architecture.puml new file mode 100644 index 0000000..6481b5e --- /dev/null +++ b/docs/src/docs/asciidoc/plantuml/welcome-physical-architecture.puml @@ -0,0 +1,43 @@ +@startuml + +left to right direction + +node "Super Hero UI" as ui { + agent "Quarkus" <> as uiQuarkus +} + +node "Fight" as fight { + agent "Quarkus" <> as fightQuarkus + database "Postgresql" as fightPostgresql + fightQuarkus .left.> fightPostgresql +} + +node "Hero" as hero { + agent "Quarkus" <> as heroQuarkus + database "Postgresql" as heroPostgresql + heroQuarkus .left.> heroPostgresql +} + +node "Villain" as villain { + agent "Quarkus" <> as villainQuarkus + database "Postgresql" as villainPostgresql + villainQuarkus .left.> villainPostgresql +} + +node "Kafka" as kafka { +} + +node "Fallback" as fallback { + agent "Quarkus" <> as fallbackQuarkus + file "File" as fallbackFile + fallbackQuarkus .left.> fallbackFile +} + +fightQuarkus ..> kafka : Message +fallback <.. kafka : Message + +uiQuarkus --> fightQuarkus : HTTP +fightQuarkus --> heroQuarkus : HTTP +fightQuarkus --> villainQuarkus : HTTP + +@enduml diff --git a/docs/src/docs/asciidoc/spine.adoc b/docs/src/docs/asciidoc/spine.adoc new file mode 100644 index 0000000..074b333 --- /dev/null +++ b/docs/src/docs/asciidoc/spine.adoc @@ -0,0 +1,29 @@ += Azure Container Apps and Java Runtimes Workshop +Antonio Goncalves +:revnumber: {project-version} +:example-caption!: + +// Welcome +include::00-welcome/welcome.adoc[leveloffset=+1] +<<< + +// Introduction +include::01-introduction/introduction.adoc[leveloffset=+1] +<<< + +// Quarkus +include::02-quarkus/quarkus.adoc[leveloffset=+1] +<<< + +// Micronaut +include::03-micronaut/micronaut.adoc[leveloffset=+1] +<<< + +// SpringBoot +include::04-springboot/springboot.adoc[leveloffset=+1] +<<< + +// Scaling +include::05-scaling/ui.adoc[leveloffset=+1] +<<< + diff --git a/pom.xml b/pom.xml index e661ccb..7508bb4 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,7 @@ pom Azure Container Apps and Java Runtimes Workshop + docs micronaut-app springboot-app quarkus-app