зеркало из
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
echo "### Bootstraps the Quarkus App"
mvn io.quarkus:quarkus-maven-plugin:3.0.0.CR1:create \
-DplatformVersion=3.0.0.CR1 \
mvn io.quarkus:quarkus-maven-plugin:3.10.0:create \
-DplatformVersion=3.10.0 \
-DprojectGroupId=io.containerapps.javaruntime.workshop \
-DprojectArtifactId=quarkus-app \
-DprojectName="Azure Container Apps and Java Runtimes Workshop :: Quarkus" \

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

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

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

@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# 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

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

@ -1,4 +1,4 @@
# quarkus-app Project
# Azure Container Apps and Java Runtimes Workshop :: Quarkus
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:
```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`.
@ -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:
```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:
```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`
@ -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
- 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
### 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
Easily start your RESTful Web Services

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

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

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

@ -77,7 +77,7 @@
# 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'
@ -90,6 +90,8 @@ COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8701
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"
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

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

@ -3,7 +3,7 @@
#
# 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:
#
@ -77,7 +77,7 @@
# 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'
@ -87,5 +87,7 @@ COPY target/*-runner.jar /deployments/quarkus-run.jar
EXPOSE 8701
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"
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

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

@ -3,7 +3,7 @@
#
# Before building the container image run:
#
# ./mvnw package -Pnative
# ./mvnw package -Dnative
#
# Then, build the image with:
#
@ -14,7 +14,7 @@
# 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/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
@ -24,4 +24,4 @@ COPY --chown=1001:root target/*-runner /work/application
EXPOSE 8701
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:
#
# ./mvnw package -Pnative
# ./mvnw package -Dnative
#
# Then, build the image with:
#
@ -27,4 +27,4 @@ COPY --chown=1001:root target/*-runner /work/application
EXPOSE 8701
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;
@QuarkusIntegrationTest
public class QuarkusResourceIT extends QuarkusResourceTest {
class QuarkusResourceIT extends QuarkusResourceTest {
// Execute the same tests but in packaged mode.
}

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

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