зеркало из
1
0
Форкнуть 0
This commit is contained in:
Antonio Goncalves 2024-05-03 10:53:05 +02:00
Родитель d31c1af1f0
Коммит e9ea6252ec
11 изменённых файлов: 62 добавлений и 37 удалений

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

@ -35,8 +35,8 @@ echo "### Bootstraps the Micronaut App"
curl --location --request GET 'https://launch.micronaut.io/create/default/io.containerapps.javaruntime.workshop.micronaut.micronaut-app?lang=JAVA&build=MAVEN&test=JUNIT&javaVersion=JDK_17&features=data-jpa&features=postgres&features=testcontainers&features=micronaut-test-rest-assured' --output micronaut-app.zip && unzip -o micronaut-app.zip && rm micronaut-app.zip curl --location --request GET 'https://launch.micronaut.io/create/default/io.containerapps.javaruntime.workshop.micronaut.micronaut-app?lang=JAVA&build=MAVEN&test=JUNIT&javaVersion=JDK_17&features=data-jpa&features=postgres&features=testcontainers&features=micronaut-test-rest-assured' --output micronaut-app.zip && unzip -o micronaut-app.zip && rm micronaut-app.zip
echo "### Bootstraps the Quarkus App" echo "### Bootstraps the Quarkus App"
mvn io.quarkus:quarkus-maven-plugin:3.0.0.CR1:create \ mvn io.quarkus:quarkus-maven-plugin:3.10.0:create \
-DplatformVersion=3.0.0.CR1 \ -DplatformVersion=3.10.0 \
-DprojectGroupId=io.containerapps.javaruntime.workshop \ -DprojectGroupId=io.containerapps.javaruntime.workshop \
-DprojectArtifactId=quarkus-app \ -DprojectArtifactId=quarkus-app \
-DprojectName="Azure Container Apps and Java Runtimes Workshop :: Quarkus" \ -DprojectName="Azure Container Apps and Java Runtimes Workshop :: Quarkus" \

3
quarkus-app/.gitignore поставляемый
Просмотреть файл

@ -38,3 +38,6 @@ nb-configuration.xml
# Local environment # Local environment
.env .env
# Plugin directory
/.quarkus/cli/plugins/

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

@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.8/apache-maven-3.8.8-bin.zip distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

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

@ -1,4 +1,4 @@
# quarkus-app Project # Azure Container Apps and Java Runtimes Workshop :: Quarkus
This project uses Quarkus, the Supersonic Subatomic Java Framework. This project uses Quarkus, the Supersonic Subatomic Java Framework.
@ -26,7 +26,7 @@ The application is now runnable using `java -jar target/quarkus-app/quarkus-run.
If you want to build an _über-jar_, execute the following command: If you want to build an _über-jar_, execute the following command:
```shell script ```shell script
./mvnw package -Dquarkus.package.type=uber-jar ./mvnw package -Dquarkus.package.jar.type=uber-jar
``` ```
The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.
@ -35,12 +35,12 @@ The application, packaged as an _über-jar_, is now runnable using `java -jar ta
You can create a native executable using: You can create a native executable using:
```shell script ```shell script
./mvnw package -Pnative ./mvnw package -Dnative
``` ```
Or, if you don't have GraalVM installed, you can run the native executable build in a container using: Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script ```shell script
./mvnw package -Pnative -Dquarkus.native.container-build=true ./mvnw package -Dnative -Dquarkus.native.container-build=true
``` ```
You can then execute your native executable with: `./target/quarkus-app-1.0.0-SNAPSHOT-runner` You can then execute your native executable with: `./target/quarkus-app-1.0.0-SNAPSHOT-runner`
@ -67,10 +67,20 @@ docker run -i --rm -p 8701:8701 \
- Hibernate ORM with Panache ([guide](https://quarkus.io/guides/hibernate-orm-panache)): Simplify your persistence code for Hibernate ORM via the active record or the repository pattern - Hibernate ORM with Panache ([guide](https://quarkus.io/guides/hibernate-orm-panache)): Simplify your persistence code for Hibernate ORM via the active record or the repository pattern
- RESTEasy Classic JSON-B ([guide](https://quarkus.io/guides/rest-json)): JSON-B serialization support for RESTEasy Classic - RESTEasy Classic JSON-B ([guide](https://quarkus.io/guides/rest-json)): JSON-B serialization support for RESTEasy Classic
- RESTEasy Classic ([guide](https://quarkus.io/guides/resteasy)): REST endpoint framework implementing JAX-RS and more - JDBC Driver - PostgreSQL ([guide](https://quarkus.io/guides/datasource)): Connect to the PostgreSQL database via JDBC
- RESTEasy Classic ([guide](https://quarkus.io/guides/resteasy)): REST endpoint framework implementing Jakarta REST and more
## Provided Code ## Provided Code
### Hibernate ORM
Create your first JPA entity
[Related guide section...](https://quarkus.io/guides/hibernate-orm)
[Related Hibernate with Panache section...](https://quarkus.io/guides/hibernate-orm-panache)
### RESTEasy JAX-RS ### RESTEasy JAX-RS
Easily start your RESTful Web Services Easily start your RESTful Web Services

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

@ -1,6 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" <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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>io.containerapps.javaruntime.workshop</groupId> <groupId>io.containerapps.javaruntime.workshop</groupId>
@ -11,17 +10,19 @@
<artifactId>quarkus-app</artifactId> <artifactId>quarkus-app</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<name>Azure Container Apps and Java Runtimes Workshop :: Quarkus</name> <name>Azure Container Apps and Java Runtimes Workshop :: Quarkus</name>
<properties> <properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version> <compiler-plugin.version>3.12.1</compiler-plugin.version>
<maven.compiler.release>17</maven.compiler.release> <maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.0.0.CR1</quarkus.platform.version> <quarkus.platform.version>3.10.0</quarkus.platform.version>
<skipITs>true</skipITs> <skipITs>true</skipITs>
<surefire-plugin.version>3.0.0</surefire-plugin.version> <surefire-plugin.version>3.2.5</surefire-plugin.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
@ -33,6 +34,7 @@
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
@ -54,6 +56,10 @@
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId> <artifactId>quarkus-arc</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId> <artifactId>quarkus-junit5</artifactId>
@ -65,6 +71,7 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -110,6 +117,8 @@
<goal>integration-test</goal> <goal>integration-test</goal>
<goal>verify</goal> <goal>verify</goal>
</goals> </goals>
</execution>
</executions>
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
@ -117,11 +126,10 @@
<maven.home>${maven.home}</maven.home> <maven.home>${maven.home}</maven.home>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<profiles> <profiles>
<profile> <profile>
<id>native</id> <id>native</id>
@ -132,7 +140,7 @@
</activation> </activation>
<properties> <properties>
<skipITs>false</skipITs> <skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type> <quarkus.native.enabled>true</quarkus.native.enabled>
</properties> </properties>
</profile> </profile>
</profiles> </profiles>

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

@ -77,7 +77,7 @@
# accessed directly. (example: "foo.example.com,bar.example.com") # accessed directly. (example: "foo.example.com,bar.example.com")
# #
### ###
FROM registry.access.redhat.com/ubi8/openjdk-17:1.14 FROM registry.access.redhat.com/ubi8/openjdk-17:1.18
ENV LANGUAGE='en_US:en' ENV LANGUAGE='en_US:en'
@ -90,6 +90,8 @@ COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8701 EXPOSE 8701
USER 185 USER 185
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 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" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

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

@ -3,7 +3,7 @@
# #
# Before building the container image run: # Before building the container image run:
# #
# ./mvnw package -Dquarkus.package.type=legacy-jar # ./mvnw package -Dquarkus.package.jar.type=legacy-jar
# #
# Then, build the image with: # Then, build the image with:
# #
@ -77,7 +77,7 @@
# accessed directly. (example: "foo.example.com,bar.example.com") # accessed directly. (example: "foo.example.com,bar.example.com")
# #
### ###
FROM registry.access.redhat.com/ubi8/openjdk-17:1.14 FROM registry.access.redhat.com/ubi8/openjdk-17:1.18
ENV LANGUAGE='en_US:en' ENV LANGUAGE='en_US:en'
@ -87,5 +87,7 @@ COPY target/*-runner.jar /deployments/quarkus-run.jar
EXPOSE 8701 EXPOSE 8701
USER 185 USER 185
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 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" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

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

@ -3,7 +3,7 @@
# #
# Before building the container image run: # Before building the container image run:
# #
# ./mvnw package -Pnative # ./mvnw package -Dnative
# #
# Then, build the image with: # Then, build the image with:
# #
@ -14,7 +14,7 @@
# docker run -i --rm -p 8701:8701 quarkus/quarkus-app # docker run -i --rm -p 8701:8701 quarkus/quarkus-app
# #
### ###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9
WORKDIR /work/ WORKDIR /work/
RUN chown 1001 /work \ RUN chown 1001 /work \
&& chmod "g+rwX" /work \ && chmod "g+rwX" /work \
@ -24,4 +24,4 @@ COPY --chown=1001:root target/*-runner /work/application
EXPOSE 8701 EXPOSE 8701
USER 1001 USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

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

@ -6,7 +6,7 @@
# #
# Before building the container image run: # Before building the container image run:
# #
# ./mvnw package -Pnative # ./mvnw package -Dnative
# #
# Then, build the image with: # Then, build the image with:
# #
@ -27,4 +27,4 @@ COPY --chown=1001:root target/*-runner /work/application
EXPOSE 8701 EXPOSE 8701
USER 1001 USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

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

@ -3,6 +3,6 @@ package io.containerapps.javaruntime.workshop.quarkus;
import io.quarkus.test.junit.QuarkusIntegrationTest; import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest @QuarkusIntegrationTest
public class QuarkusResourceIT extends QuarkusResourceTest { class QuarkusResourceIT extends QuarkusResourceTest {
// Execute the same tests but in packaged mode. // Execute the same tests but in packaged mode.
} }

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

@ -8,12 +8,12 @@ import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
@QuarkusTest @QuarkusTest
public class QuarkusResourceTest { class QuarkusResourceTest {
// end::adocHeader[] // end::adocHeader[]
// tag::adocTestHello[] // tag::adocTestHello[]
@Test @Test
public void testHelloEndpoint() { void testHelloEndpoint() {
given() given()
.when().get("/quarkus") .when().get("/quarkus")
.then() .then()
@ -23,7 +23,7 @@ public class QuarkusResourceTest {
// end::adocTestHello[] // end::adocTestHello[]
@Test @Test
public void testCpuEndpoint() { void testCpuEndpoint() {
given().param("iterations", 1) given().param("iterations", 1)
.when().get("/quarkus/cpu") .when().get("/quarkus/cpu")
.then() .then()
@ -33,7 +33,7 @@ public class QuarkusResourceTest {
} }
@Test @Test
public void testCpuWithDBEndpoint() { void testCpuWithDBEndpoint() {
given().param("iterations", 1).param("db", true) given().param("iterations", 1).param("db", true)
.when().get("/quarkus/cpu") .when().get("/quarkus/cpu")
.then() .then()
@ -44,7 +44,7 @@ public class QuarkusResourceTest {
// tag::adocTestCPU[] // tag::adocTestCPU[]
@Test @Test
public void testCpuWithDBAndDescEndpoint() { void testCpuWithDBAndDescEndpoint() {
given().param("iterations", 1).param("db", true).param("desc", "Java17") given().param("iterations", 1).param("db", true).param("desc", "Java17")
.when().get("/quarkus/cpu") .when().get("/quarkus/cpu")
.then() .then()
@ -56,7 +56,7 @@ public class QuarkusResourceTest {
// end::adocTestCPU[] // end::adocTestCPU[]
@Test @Test
public void testMemoryEndpoint() { void testMemoryEndpoint() {
given().param("bites", 1) given().param("bites", 1)
.when().get("/quarkus/memory") .when().get("/quarkus/memory")
.then() .then()
@ -66,7 +66,7 @@ public class QuarkusResourceTest {
} }
@Test @Test
public void testMemoryWithDBEndpoint() { void testMemoryWithDBEndpoint() {
given().param("bites", 1).param("db", true) given().param("bites", 1).param("db", true)
.when().get("/quarkus/memory") .when().get("/quarkus/memory")
.then() .then()
@ -77,7 +77,7 @@ public class QuarkusResourceTest {
// tag::adocTestMemory[] // tag::adocTestMemory[]
@Test @Test
public void testMemoryWithDBAndDescEndpoint() { void testMemoryWithDBAndDescEndpoint() {
given().param("bites", 1).param("db", true).param("desc", "Java17") given().param("bites", 1).param("db", true).param("desc", "Java17")
.when().get("/quarkus/memory") .when().get("/quarkus/memory")
.then() .then()
@ -90,7 +90,7 @@ public class QuarkusResourceTest {
// tag::adocTestStats[] // tag::adocTestStats[]
@Test @Test
public void testStats() { void testStats() {
given() given()
.when().get("/quarkus/stats") .when().get("/quarkus/stats")
.then() .then()