зеркало из
1
0
Форкнуть 0
This commit is contained in:
Antonio Goncalves 2022-09-14 10:04:33 +02:00
Родитель 36a8b688cd
Коммит 678d4f5a0b
15 изменённых файлов: 608 добавлений и 0 удалений

20
.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

24
docs/.editorconfig Normal file
Просмотреть файл

@ -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

44
docs/.gitignore поставляемый Normal file
Просмотреть файл

@ -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

9
docs/README.md Normal file
Просмотреть файл

@ -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.

94
docs/pom.xml Normal file
Просмотреть файл

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.containerapps.javaruntime.workshop</groupId>
<artifactId>docs</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Azure Container Apps and Java Runtimes Workshop :: Documentation</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<asciidoctor.maven.plugin.version>2.2.2</asciidoctor.maven.plugin.version>
</properties>
<build>
<defaultGoal>process-resources</defaultGoal>
<plugins>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>${asciidoctor.maven.plugin.version}</version>
<dependencies>
</dependencies>
<configuration>
<!-- Attributes common to all output formats -->
<attributes>
<project-version>${project.version}</project-version>
<allow-uri-read/>
<imagesdir>./images</imagesdir>
<plantDir>./plantuml</plantDir>
<revdate>${revision.date}</revdate>
<attribute-missing>warn</attribute-missing>
<doctype>book</doctype>
<sectlinks/>
<sectanchors/>
<!-- Code Source -->
<source-highlighter>coderay</source-highlighter>
<source-language>java</source-language>
<!-- Captions -->
<xrefstyle>short</xrefstyle>
<listing-caption>Listing</listing-caption>
<appendix-caption>Appendix</appendix-caption>
<table-caption>Table</table-caption>
<!-- Images -->
<icons>font</icons>
<data-uri/>
<figure-caption>Figure</figure-caption>
<!-- TOC -->
<toc/>
<toclevels>3</toclevels>
<toc>left</toc>
<!-- Java -->
<jdk-version>11</jdk-version>
<maven-version>3.8.x</maven-version>
<!-- ============= -->
<!-- = Workshop = -->
<!-- ============= -->
<workshop-github-url>https://github.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop</workshop-github-url>
<workshop-github-issue>https://github.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/issues</workshop-github-issue>
<workshop-github-clone>https://github.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop.git</workshop-github-clone>
<!-- Fights -->
<fights-github-raw>https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/fights-app</fights-github-raw>
<!-- Heroes -->
<heroes-github-raw>https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/heroes-app</heroes-github-raw>
<!-- Villains -->
<villains-github-raw>https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/villains-app</villains-github-raw>
<!-- UI -->
<ui-github-raw>https://raw.githubusercontent.com/amadeus4dev-events/1ahack4sustainability-containerapps-quarkus-workshop/main/super-heroes-ui</ui-github-raw>
</attributes>
</configuration>
<executions>
<execution>
<id>asciidoc-to-html</id>
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html5</backend>
<attributes>
<sectanchors>true</sectanchors>
<!-- set the idprefix to blank -->
<idprefix/>
<idseparator>-</idseparator>
</attributes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Просмотреть файл

@ -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

Просмотреть файл

@ -0,0 +1,10 @@
[[introduction]]
= Introduction
== What is Azure Container Apps?
== What is GitHub Actions?
== What is CodeSpaces and VS Code?
== What is Quarkus?

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Двоичные данные
docs/src/docs/asciidoc/images/sunset.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 120 KiB

Просмотреть файл

@ -0,0 +1,43 @@
@startuml
left to right direction
node "Super Hero UI" as ui {
agent "Quarkus" <<frontend>> as uiQuarkus
}
node "Fight" as fight {
agent "Quarkus" <<application>> as fightQuarkus
database "Postgresql" as fightPostgresql
fightQuarkus .left.> fightPostgresql
}
node "Hero" as hero {
agent "Quarkus" <<application>> as heroQuarkus
database "Postgresql" as heroPostgresql
heroQuarkus .left.> heroPostgresql
}
node "Villain" as villain {
agent "Quarkus" <<application>> as villainQuarkus
database "Postgresql" as villainPostgresql
villainQuarkus .left.> villainPostgresql
}
node "Kafka" as kafka {
}
node "Fallback" as fallback {
agent "Quarkus" <<application>> 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

Просмотреть файл

@ -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]
<<<

Просмотреть файл

@ -8,6 +8,7 @@
<packaging>pom</packaging>
<name>Azure Container Apps and Java Runtimes Workshop</name>
<modules>
<module>docs</module>
<module>micronaut-app</module>
<module>springboot-app</module>
<module>quarkus-app</module>