Skip to content

Commit c83e3d3

Browse files
authored
Merge pull request #168 from redhat-developer-demos/swapi
Replace Fruit with Movie and FruityVice with Swapi.dev
2 parents a5fda30 + a6cbf20 commit c83e3d3

29 files changed

+1070
-401
lines changed

apps/tutorial_app/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!target/*-runner
3+
!target/*-runner.jar
4+
!target/lib/*
5+
!target/quarkus-app/*

apps/tutorial_app/.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#Maven
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
release.properties
7+
.flattened-pom.xml
8+
9+
# Eclipse
10+
.project
11+
.classpath
12+
.settings/
13+
bin/
14+
15+
# IntelliJ
16+
.idea
17+
*.ipr
18+
*.iml
19+
*.iws
20+
21+
# NetBeans
22+
nb-configuration.xml
23+
24+
# Visual Studio Code
25+
.vscode
26+
.factorypath
27+
28+
# OSX
29+
.DS_Store
30+
31+
# Vim
32+
*.swp
33+
*.swo
34+
35+
# patch
36+
*.orig
37+
*.rej
38+
39+
# Local environment
40+
.env
41+
42+
# Plugin directory
43+
/.quarkus/cli/plugins/
44+
# TLS Certificates
45+
.certs/

apps/tutorial_app/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# quarkus1and2
2+
3+
This project uses Quarkus, the Supersonic Subatomic Java Framework.
4+
5+
If you want to learn more about Quarkus, please visit its website: <https://quarkus.io/>.
6+
7+
## Running the application in dev mode
8+
9+
You can run your application in dev mode that enables live coding using:
10+
11+
```shell script
12+
./mvnw compile quarkus:dev
13+
```
14+
15+
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at <http://localhost:8080/q/dev/>.
16+
17+
## Packaging and running the application
18+
19+
The application can be packaged using:
20+
21+
```shell script
22+
./mvnw package
23+
```
24+
25+
It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
26+
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
27+
28+
The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
29+
30+
If you want to build an _über-jar_, execute the following command:
31+
32+
```shell script
33+
./mvnw package -Dquarkus.package.jar.type=uber-jar
34+
```
35+
36+
The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.
37+
38+
## Creating a native executable
39+
40+
You can create a native executable using:
41+
42+
```shell script
43+
./mvnw package -Dnative
44+
```
45+
46+
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
47+
48+
```shell script
49+
./mvnw package -Dnative -Dquarkus.native.container-build=true
50+
```
51+
52+
You can then execute your native executable with: `./target/quarkus1and2-1.0-SNAPSHOT-runner`
53+
54+
If you want to learn more about building native executables, please consult <https://quarkus.io/guides/maven-tooling>.
55+
56+
## Related Guides
57+
58+
- REST ([guide](https://quarkus.io/guides/rest)): A Jakarta REST implementation utilizing build time processing and Vert.x. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.
59+
60+
## Provided Code
61+
62+
### REST
63+
64+
Easily start your REST Web Services
65+
66+
[Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3+
#
4+
# Before building the container image run:
5+
#
6+
# ./mvnw package
7+
#
8+
# Then, build the image with:
9+
#
10+
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus1and2-jvm .
11+
#
12+
# Then run the container using:
13+
#
14+
# docker run -i --rm -p 8080:8080 quarkus/quarkus1and2-jvm
15+
#
16+
# If you want to include the debug port into your docker image
17+
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
18+
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
19+
# when running the container
20+
#
21+
# Then run the container using :
22+
#
23+
# docker run -i --rm -p 8080:8080 quarkus/quarkus1and2-jvm
24+
#
25+
# This image uses the `run-java.sh` script to run the application.
26+
# This scripts computes the command line to execute your Java application, and
27+
# includes memory/GC tuning.
28+
# You can configure the behavior using the following environment properties:
29+
# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class")
30+
# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
31+
# in JAVA_OPTS (example: "-Dsome.property=foo")
32+
# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
33+
# used to calculate a default maximal heap memory based on a containers restriction.
34+
# If used in a container without any memory constraints for the container then this
35+
# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
36+
# of the container available memory as set here. The default is `50` which means 50%
37+
# of the available memory is used as an upper boundary. You can skip this mechanism by
38+
# setting this value to `0` in which case no `-Xmx` option is added.
39+
# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
40+
# is used to calculate a default initial heap memory based on the maximum heap memory.
41+
# If used in a container without any memory constraints for the container then this
42+
# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
43+
# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
44+
# is used as the initial heap size. You can skip this mechanism by setting this value
45+
# to `0` in which case no `-Xms` option is added (example: "25")
46+
# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
47+
# This is used to calculate the maximum value of the initial heap memory. If used in
48+
# a container without any memory constraints for the container then this option has
49+
# no effect. If there is a memory constraint then `-Xms` is limited to the value set
50+
# here. The default is 4096MB which means the calculated value of `-Xms` never will
51+
# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
52+
# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
53+
# when things are happening. This option, if set to true, will set
54+
# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
55+
# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
56+
# true").
57+
# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
58+
# - CONTAINER_CORE_LIMIT: A calculated core limit as described in
59+
# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
60+
# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
61+
# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
62+
# (example: "20")
63+
# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
64+
# (example: "40")
65+
# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
66+
# (example: "4")
67+
# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
68+
# previous GC times. (example: "90")
69+
# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
70+
# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
71+
# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
72+
# contain the necessary JRE command-line options to specify the required GC, which
73+
# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
74+
# - HTTPS_PROXY: The location of the https proxy. (example: "[email protected]:8080")
75+
# - HTTP_PROXY: The location of the http proxy. (example: "[email protected]:8080")
76+
# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
77+
# accessed directly. (example: "foo.example.com,bar.example.com")
78+
#
79+
###
80+
FROM registry.access.redhat.com/ubi8/openjdk-21:1.20
81+
82+
ENV LANGUAGE='en_US:en'
83+
84+
85+
# We make four distinct layers so if there are application changes the library layers can be re-used
86+
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
87+
COPY --chown=185 target/quarkus-app/*.jar /deployments/
88+
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
89+
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
90+
91+
EXPOSE 8080
92+
USER 185
93+
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
94+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
95+
96+
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
97+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3+
#
4+
# Before building the container image run:
5+
#
6+
# ./mvnw package -Dquarkus.package.jar.type=legacy-jar
7+
#
8+
# Then, build the image with:
9+
#
10+
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/quarkus1and2-legacy-jar .
11+
#
12+
# Then run the container using:
13+
#
14+
# docker run -i --rm -p 8080:8080 quarkus/quarkus1and2-legacy-jar
15+
#
16+
# If you want to include the debug port into your docker image
17+
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
18+
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
19+
# when running the container
20+
#
21+
# Then run the container using :
22+
#
23+
# docker run -i --rm -p 8080:8080 quarkus/quarkus1and2-legacy-jar
24+
#
25+
# This image uses the `run-java.sh` script to run the application.
26+
# This scripts computes the command line to execute your Java application, and
27+
# includes memory/GC tuning.
28+
# You can configure the behavior using the following environment properties:
29+
# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class")
30+
# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
31+
# in JAVA_OPTS (example: "-Dsome.property=foo")
32+
# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
33+
# used to calculate a default maximal heap memory based on a containers restriction.
34+
# If used in a container without any memory constraints for the container then this
35+
# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
36+
# of the container available memory as set here. The default is `50` which means 50%
37+
# of the available memory is used as an upper boundary. You can skip this mechanism by
38+
# setting this value to `0` in which case no `-Xmx` option is added.
39+
# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
40+
# is used to calculate a default initial heap memory based on the maximum heap memory.
41+
# If used in a container without any memory constraints for the container then this
42+
# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
43+
# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
44+
# is used as the initial heap size. You can skip this mechanism by setting this value
45+
# to `0` in which case no `-Xms` option is added (example: "25")
46+
# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
47+
# This is used to calculate the maximum value of the initial heap memory. If used in
48+
# a container without any memory constraints for the container then this option has
49+
# no effect. If there is a memory constraint then `-Xms` is limited to the value set
50+
# here. The default is 4096MB which means the calculated value of `-Xms` never will
51+
# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
52+
# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
53+
# when things are happening. This option, if set to true, will set
54+
# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
55+
# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
56+
# true").
57+
# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
58+
# - CONTAINER_CORE_LIMIT: A calculated core limit as described in
59+
# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
60+
# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
61+
# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
62+
# (example: "20")
63+
# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
64+
# (example: "40")
65+
# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
66+
# (example: "4")
67+
# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
68+
# previous GC times. (example: "90")
69+
# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
70+
# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
71+
# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
72+
# contain the necessary JRE command-line options to specify the required GC, which
73+
# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
74+
# - HTTPS_PROXY: The location of the https proxy. (example: "[email protected]:8080")
75+
# - HTTP_PROXY: The location of the http proxy. (example: "[email protected]:8080")
76+
# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
77+
# accessed directly. (example: "foo.example.com,bar.example.com")
78+
#
79+
###
80+
FROM registry.access.redhat.com/ubi8/openjdk-21:1.20
81+
82+
ENV LANGUAGE='en_US:en'
83+
84+
85+
COPY target/lib/* /deployments/lib/
86+
COPY target/*-runner.jar /deployments/quarkus-run.jar
87+
88+
EXPOSE 8080
89+
USER 185
90+
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
91+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
92+
93+
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
3+
#
4+
# Before building the container image run:
5+
#
6+
# ./mvnw package -Dnative
7+
#
8+
# Then, build the image with:
9+
#
10+
# docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus1and2 .
11+
#
12+
# Then run the container using:
13+
#
14+
# docker run -i --rm -p 8080:8080 quarkus/quarkus1and2
15+
#
16+
###
17+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10
18+
WORKDIR /work/
19+
RUN chown 1001 /work \
20+
&& chmod "g+rwX" /work \
21+
&& chown 1001:root /work
22+
COPY --chown=1001:root target/*-runner /work/application
23+
24+
EXPOSE 8080
25+
USER 1001
26+
27+
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
3+
# It uses a micro base image, tuned for Quarkus native executables.
4+
# It reduces the size of the resulting container image.
5+
# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image.
6+
#
7+
# Before building the container image run:
8+
#
9+
# ./mvnw package -Dnative
10+
#
11+
# Then, build the image with:
12+
#
13+
# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/quarkus1and2 .
14+
#
15+
# Then run the container using:
16+
#
17+
# docker run -i --rm -p 8080:8080 quarkus/quarkus1and2
18+
#
19+
###
20+
FROM quay.io/quarkus/quarkus-micro-image:2.0
21+
WORKDIR /work/
22+
RUN chown 1001 /work \
23+
&& chmod "g+rwX" /work \
24+
&& chown 1001:root /work
25+
COPY --chown=1001:root target/*-runner /work/application
26+
27+
EXPOSE 8080
28+
USER 1001
29+
30+
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.redhat.developers;
2+
3+
import io.smallrye.health.checks.UrlHealthCheck;
4+
import org.eclipse.microprofile.config.inject.ConfigProperty;
5+
import org.eclipse.microprofile.health.HealthCheck;
6+
import org.eclipse.microprofile.health.Readiness;
7+
8+
import jakarta.enterprise.context.ApplicationScoped;
9+
import jakarta.ws.rs.HttpMethod;
10+
11+
@ApplicationScoped
12+
public class CustomHealthCheck {
13+
14+
@ConfigProperty(name = "quarkus.rest-client.\"com.redhat.developers.SwapiService\".url")
15+
String externalURL;
16+
17+
@Readiness
18+
HealthCheck checkURL() {
19+
return new UrlHealthCheck(externalURL+"/api/films/")
20+
.name("ExternalURL health check").requestMethod(HttpMethod.GET).statusCode(200);
21+
}
22+
23+
}

0 commit comments

Comments
 (0)