Skip to content

Commit

Permalink
Initial Java 21 support
Browse files Browse the repository at this point in the history
  • Loading branch information
edeandrea committed Nov 1, 2023
1 parent 0bc9435 commit cb5ff9f
Show file tree
Hide file tree
Showing 37 changed files with 590 additions and 100 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/build-push-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Build and Push Container images

env:
IMAGE_BASE_NAME: "quay.io/quarkus-super-heroes"
MANDREL_IMAGE: "quay.io/quarkus/ubi-quarkus-mandrel-builder-image"
MANDREL_VERSION: "23.0"
GRAALVM_IMAGE: "quay.io/quarkus/ubi-quarkus-graalvmce-builder-image"
LATEST_IMAGE_TAG: "latest"

on:
Expand All @@ -28,6 +27,7 @@ jobs:
matrix:
java:
- '17'
- '21'
project:
- event-statistics
- rest-fights
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
distribution: zulu
cache: maven

- name: Create env vars
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
fail-fast: false
matrix:
java:
- '17'
- '21'
project:
- event-statistics
- rest-fights
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
distribution: zulu
cache: maven

- name: Create env vars
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
-Dmaven.compiler.release=${{ matrix.java }} \
-Dquarkus.http.host=0.0.0.0 \
-Dquarkus.native.container-build=true \
-Dquarkus.native.builder-image=${{ env.MANDREL_IMAGE }}:${{ env.MANDREL_VERSION }}-java${{ matrix.java }} \
-Dquarkus.native.builder-image=${{ env.GRAALVM_IMAGE }}:jdk-${{ matrix.java }} \
-Dquarkus.native.container-runtime-options=--platform=linux/${{ matrix.arch }} \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=false \
Expand All @@ -204,6 +204,7 @@ jobs:
matrix:
java:
- '17'
- '21'
kind:
- ""
- "native-"
Expand All @@ -218,10 +219,12 @@ jobs:
arch:
- amd64
- arm64
# Until https://github.com/microsoft/semantic-kernel/issues/2885 is resolved
exclude:
# Until https://github.com/microsoft/semantic-kernel/issues/2885 is resolved
- project: rest-narration
kind: "native-"
- java: 17
kind: "native-"
name: "Push app images (${{ matrix.arch }}-${{ matrix.project }}-${{ matrix.kind }}java${{ matrix.java }})"
steps:
- name: Calculate Branch (workflow_run event)
Expand Down Expand Up @@ -312,6 +315,7 @@ jobs:
matrix:
java:
- '17'
- '21'
kind:
- ""
- "native-"
Expand All @@ -323,10 +327,12 @@ jobs:
- rest-narration
- grpc-locations
- ui-super-heroes
# Until https://github.com/microsoft/semantic-kernel/issues/2885 is resolved
exclude:
# Until https://github.com/microsoft/semantic-kernel/issues/2885 is resolved
- project: rest-narration
kind: "native-"
- java: 17
kind: "native-"
name: Create app multiarch manifests (${{ matrix.project }}-${{ matrix.kind }}java${{ matrix.java }})
steps:
- name: Calculate Branch (workflow_run event)
Expand Down
31 changes: 15 additions & 16 deletions .github/workflows/simple-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Basic build and test

env:
MANDREL_VERSION: "23.0.1.2-Final"

on:
push:
paths-ignore:
Expand Down Expand Up @@ -56,6 +53,7 @@ jobs:
matrix:
java:
- '17'
- '21'
project:
- event-statistics
- rest-fights
Expand All @@ -72,7 +70,7 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
distribution: zulu
cache: maven

- name: "build-test-jvm-${{ matrix.project }}-java-${{ matrix.java }}"
Expand All @@ -89,7 +87,8 @@ jobs:
fail-fast: false
matrix:
java:
- '17'
- { graal: '17.0.8', java: '17' }
- { graal: '21.0.0', java: '21'}
project:
- event-statistics
- rest-fights
Expand All @@ -103,25 +102,25 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache and restore Mandrel distro
id: check-mandrel-cache
- name: Cache and restore GraalVM CE (${{ matrix.java.graal }})
id: check-graal-cache
uses: actions/cache@v3
with:
path: mandrel-${{ env.MANDREL_VERSION }}-${{ matrix.java }}.tar.gz
key: mandrel-distro-${{ env.MANDREL_VERSION }}-${{ matrix.java }}
path: graalvm-community-jdk-${{ matrix.java.graal }}_linux-x64_bin.tar.gz
key: graal-distro-${{ matrix.java.graal }}

- name: Download Mandrel
if: steps.check-mandrel-cache.outputs.cache-hit != 'true'
- name: Download GraalVM CE ${{ matrix.java.graal }}
if: steps.check-graal-cache.outputs.cache-hit != 'true'
run: |
download_url="https://github.com/graalvm/mandrel/releases/download/mandrel-${MANDREL_VERSION}/mandrel-java${{ matrix.java }}-linux-amd64-${MANDREL_VERSION}.tar.gz"
wget -q -O mandrel-${{ env.MANDREL_VERSION }}-${{ matrix.java }}.tar.gz $download_url
download_url="https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${{ matrix.java.graal }}/graalvm-community-jdk-${{ matrix.java.graal }}_linux-x64_bin.tar.gz"
wget -q -O graalvm-community-jdk-${{ matrix.java.graal }}_linux-x64_bin.tar.gz $download_url
- name: Setup Maven+OpenJDK Distro
- name: Setup GraalVM CE ${{ matrix.java.graal }} distro
uses: actions/setup-java@v3
with:
distribution: 'jdkfile'
jdkFile: mandrel-${{ env.MANDREL_VERSION }}-${{ matrix.java }}.tar.gz
java-version: ${{ matrix.java }}
jdkFile: graalvm-community-jdk-${{ matrix.java.graal }}_linux-x64_bin.tar.gz
java-version: ${{ matrix.java.java }}
architecture: x64
cache: maven

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

This is a sample application demonstrating Quarkus features and best practices. The application allows superheroes to fight against supervillains. The application consists of several microservices, communicating either synchronously via REST or asynchronously using Kafka. All the data used by the applications are [on the `characterdata` branch](https://github.com/quarkusio/quarkus-super-heroes/tree/characterdata) of this repository.

The base JVM version for all the applications is Java 17.
The base JVM version for all the applications is Java 17 but Java 21 is also supported.

- [Super Hero Battle UI](ui-super-heroes)
- An Angular application to pick up a random superhero, a random supervillain, and makes them fight.
Expand Down Expand Up @@ -86,6 +86,7 @@ Pick one of the 4 versions of the application from the table below and execute t
| Description | Image Tag | Docker Compose Run Command | Docker Compose Run Command with Monitoring |
|-------------|-----------------|--------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| JVM Java 17 | `java17-latest` | `docker compose -f deploy/docker-compose/java17.yml up --remove-orphans` | `docker compose -f deploy/docker-compose/java17.yml -f deploy/docker-compose/monitoring.yml up --remove-orphans` |
| JVM Java 21 | `java21-latest` | `docker compose -f deploy/docker-compose/java21.yml up --remove-orphans` | `docker compose -f deploy/docker-compose/java21.yml -f deploy/docker-compose/monitoring.yml up --remove-orphans` |
| Native | `native-latest` | `docker compose -f deploy/docker-compose/native.yml up --remove-orphans` | `docker compose -f deploy/docker-compose/native.yml -f deploy/docker-compose/monitoring.yml up --remove-orphans` |

> **NOTE:** If your system does not have the `compose` sub-command, you can try the above commands with the `docker-compose` command instead of `docker compose`.
Expand Down Expand Up @@ -124,6 +125,7 @@ Pick one of the 4 versions of the system from the table below and deploy the app
| Description | Image Tag | OpenShift Descriptor | Minikube Descriptor | Kubernetes Descriptor | KNative Descriptor |
|-------------|-----------------|-----------------------------------------------------------|---------------------------------------------------------|-------------------------------------------------------------|-------------------------------------------------------|
| JVM Java 17 | `java17-latest` | [`java17-openshift.yml`](deploy/k8s/java17-openshift.yml) | [`java17-minikube.yml`](deploy/k8s/java17-minikube.yml) | [`java17-kubernetes.yml`](deploy/k8s/java17-kubernetes.yml) | [`java17-knative.yml`](deploy/k8s/java17-knative.yml) |
| JVM Java 21 | `java21-latest` | [`java21-openshift.yml`](deploy/k8s/java21-openshift.yml) | [`java21-minikube.yml`](deploy/k8s/java21-minikube.yml) | [`java21-kubernetes.yml`](deploy/k8s/java21-kubernetes.yml) | [`java21-knative.yml`](deploy/k8s/java21-knative.yml) |
| Native | `native-latest` | [`native-openshift.yml`](deploy/k8s/native-openshift.yml) | [`native-minikube.yml`](deploy/k8s/native-minikube.yml) | [`native-kubernetes.yml`](deploy/k8s/native-kubernetes.yml) | [`native-knative.yml`](deploy/k8s/native-knative.yml) |

### Monitoring
Expand Down
24 changes: 15 additions & 9 deletions event-statistics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ By default, the application is configured with the following:
## Running Locally via Docker Compose
Pre-built images for this application can be found at [`quay.io/quarkus-super-heroes/event-statistics`](https://quay.io/repository/quarkus-super-heroes/event-statistics?tab=tags).

Pick one of the 4 versions of the application from the table below and execute the appropriate docker compose command from the `quarkus-super-heroes/event-statistics` directory.
Pick one of the versions of the application from the table below and execute the appropriate docker compose command from the `quarkus-super-heroes/event-statistics` directory.

> **NOTE**: You may see errors as the applications start up. This may happen if an application completes startup before one if its required services (i.e. database, kafka, etc). This is fine. Once everything completes startup things will work fine.
| Description | Image Tag | Docker Compose Run Command |
|-------------|-----------------|--------------------------------------------------------------------------|
| JVM Java 17 | `java17-latest` | `docker compose -f deploy/docker-compose/java17.yml up --remove-orphans` |
| JVM Java 21 | `java21-latest` | `docker compose -f deploy/docker-compose/java21.yml up --remove-orphans` |
| Native | `native-latest` | `docker compose -f deploy/docker-compose/native.yml up --remove-orphans` |

These Docker Compose files are meant for standing up this application and the required Kafka broker only. If you want to stand up the entire system, [follow these instructions](../README.md#running-locally-via-docker-compose).
Expand All @@ -105,11 +106,12 @@ Pre-built images for this application can be found at [`quay.io/quarkus-super-he

Deployment descriptors for these images are provided in the [`deploy/k8s`](deploy/k8s) directory. There are versions for [OpenShift](https://www.openshift.com), [Minikube](https://quarkus.io/guides/deploying-to-kubernetes#deploying-to-minikube), [Kubernetes](https://www.kubernetes.io), and [KNative](https://knative.dev).

Pick one of the 4 versions of the application from the table below and deploy the appropriate descriptor from the [`deploy/k8s` directory](deploy/k8s).
Pick one of the versions of the application from the table below and deploy the appropriate descriptor from the [`deploy/k8s` directory](deploy/k8s).

| Description | Image Tag | OpenShift Descriptor | Minikube Descriptor | Kubernetes Descriptor | KNative Descriptor |
|-------------|-----------------|-----------------------------------------------------------|---------------------------------------------------------|-------------------------------------------------------------|-------------------------------------------------------|
| JVM Java 17 | `java17-latest` | [`java17-openshift.yml`](deploy/k8s/java17-openshift.yml) | [`java17-minikube.yml`](deploy/k8s/java17-minikube.yml) | [`java17-kubernetes.yml`](deploy/k8s/java17-kubernetes.yml) | [`java17-knative.yml`](deploy/k8s/java17-knative.yml) |
| JVM Java 21 | `java21-latest` | [`java21-openshift.yml`](deploy/k8s/java21-openshift.yml) | [`java21-minikube.yml`](deploy/k8s/java21-minikube.yml) | [`java21-kubernetes.yml`](deploy/k8s/java21-kubernetes.yml) | [`java21-knative.yml`](deploy/k8s/java21-knative.yml) |
| Native | `native-latest` | [`native-openshift.yml`](deploy/k8s/native-openshift.yml) | [`native-minikube.yml`](deploy/k8s/native-minikube.yml) | [`native-kubernetes.yml`](deploy/k8s/native-kubernetes.yml) | [`native-knative.yml`](deploy/k8s/native-knative.yml) |

The application is exposed outside of the cluster on port `80`.
Expand All @@ -121,13 +123,17 @@ Following the [deployment section](https://quarkus.io/guides/deploying-to-kubern

> **NOTE:** For non-OpenShift or minikube Kubernetes variants, you will most likely need to [push the image to a container registry](https://quarkus.io/guides/container-image#pushing) by adding the `-Dquarkus.container-image.push=true` flag, as well as setting the `quarkus.container-image.registry`, `quarkus.container-image.group`, and/or the `quarkus.container-image.name` properties to different values.
| Target Platform | Java Version | Command |
|------------------------|:------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Kubernetes | 17 | `./mvnw clean package -Dquarkus.profile=kubernetes -Dquarkus.kubernetes.deploy=true -DskipTests` |
| OpenShift | 17 | `./mvnw clean package -Dquarkus.profile=openshift -Dquarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 -Dquarkus.container-image.group=$(oc project -q) -Dquarkus.kubernetes.deploy=true -DskipTests` |
| Minikube | 17 | `./mvnw clean package -Dquarkus.profile=minikube -Dquarkus.kubernetes.deploy=true -DskipTests` |
| KNative | 17 | `./mvnw clean package -Dquarkus.profile=knative -Dquarkus.kubernetes.deploy=true -DskipTests` |
| KNative (on OpenShift) | 17 | `./mvnw clean package -Dquarkus.profile=knative-openshift -Dquarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 -Dquarkus.container-image.group=$(oc project -q) -Dquarkus.kubernetes.deploy=true -DskipTests` |
| Target Platform | Java Version | Command |
|------------------------|:------------:|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Kubernetes | 17 | `./mvnw clean package -Dquarkus.profile=kubernetes -Dquarkus.kubernetes.deploy=true -DskipTests` |
| Kubernetes | 21 | `./mvnw clean package -Dquarkus.profile=kubernetes-21 -Dquarkus.kubernetes.deploy=true -DskipTests` |
| OpenShift | 17 | `./mvnw clean package -Dquarkus.profile=openshift -Dquarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 -Dquarkus.container-image.group=$(oc project -q) -Dquarkus.kubernetes.deploy=true -DskipTests` |
| OpenShift | 21 | `./mvnw clean package -Dquarkus.profile=openshift-21 -Dquarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 -Dquarkus.container-image.group=$(oc project -q) -Dquarkus.kubernetes.deploy=true -DskipTests` |
| Minikube | 17 | `./mvnw clean package -Dquarkus.profile=minikube -Dquarkus.kubernetes.deploy=true -DskipTests` |
| Minikube | 21 | `./mvnw clean package -Dquarkus.profile=minikube-21 -Dquarkus.kubernetes.deploy=true -DskipTests` |
| KNative | 17 | `./mvnw clean package -Dquarkus.profile=knative -Dquarkus.kubernetes.deploy=true -DskipTests` |
| KNative (on OpenShift) | 17 | `./mvnw clean package -Dquarkus.profile=knative-openshift -Dquarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 -Dquarkus.container-image.group=$(oc project -q) -Dquarkus.kubernetes.deploy=true -DskipTests` |
| KNative (on OpenShift) | 21 | `./mvnw clean package -Dquarkus.profile=knative-openshift-21 -Dquarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 -Dquarkus.container-image.group=$(oc project -q) -Dquarkus.kubernetes.deploy=true -DskipTests` |

You may need to adjust other configuration options as well (see [Quarkus Kubernetes Extension configuration options](https://quarkus.io/guides/deploying-to-kubernetes#configuration-options) and [Quarkus OpenShift Extension configuration options](https://quarkus.io/guides/deploying-to-openshift#configuration-reference)).

Expand Down
26 changes: 26 additions & 0 deletions event-statistics/src/main/docker-compose/java21.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

event-statistics-java21:
image: quay.io/quarkus-super-heroes/event-statistics:java21-latest
container_name: event-statistics-java21
depends_on:
- apicurio
- fights-kafka
ports:
- "8085:8085"
environment:
KAFKA_BOOTSTRAP_SERVERS: PLAINTEXT://fights-kafka:9092
MP_MESSAGING_CONNECTOR_SMALLRYE_KAFKA_APICURIO_REGISTRY_URL: http://apicurio:8086/apis/registry/v2
QUARKUS_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://otel-collector:4317
restart: on-failure
networks:
default:
aliases:
- event-statistics
deploy:
resources:
limits:
memory: 1G
cpus: '1'
reservations:
memory: 256M
cpus: '0.5'
Loading

0 comments on commit cb5ff9f

Please sign in to comment.