From 666ed4289d2693e9ee9af1f60f9b18c3c5fa4a06 Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Tue, 22 Apr 2025 21:00:53 -0400 Subject: [PATCH] Move the Quarkus examples under the Quarkus extension. --- pom.xml | 3 - quarkus-proxy-wasm-example/.gitignore | 45 ------- quarkus-proxy-wasm-example/pom.xml | 123 ------------------ .../proxywasm/jaxrs/example/App.java | 47 ------- .../proxywasm/jaxrs/example/Resources.java | 33 ----- .../jaxrs/example/ResourcesTest.java | 29 ----- .../corazawaf-example/.dockerignore | 5 + .../corazawaf-example/README.md | 62 +++++++++ .../corazawaf-example}/pom.xml | 36 +++-- .../src/main/docker/Dockerfile.jvm | 98 ++++++++++++++ .../src/main/docker/Dockerfile.legacy-jar | 94 +++++++++++++ .../src/main/docker/Dockerfile.native | 29 +++++ .../src/main/docker/Dockerfile.native-micro | 32 +++++ .../src/main/java/org}/example/Admin.java | 4 +- .../src/main/java/org}/example/Anything.java | 2 +- .../src/main/java/org}/example/App.java | 2 +- .../src/main/java/org}/example/Status.java | 2 +- .../src/main/resources/application.properties | 0 .../src/main/resources/org}/example/README.md | 0 .../org}/example/coraza-proxy-wasm.wasm | Bin .../resources/org}/example/waf-config.json | 0 .../test/java/org}/example/ResourcesTest.java | 2 +- .../kuadrant-example/.dockerignore | 5 + .../kuadrant-example/README.md | 62 +++++++++ .../kuadrant-example}/pom.xml | 44 ++++--- .../src/main/docker/Dockerfile.jvm | 98 ++++++++++++++ .../src/main/docker/Dockerfile.legacy-jar | 94 +++++++++++++ .../src/main/docker/Dockerfile.native | 29 +++++ .../src/main/docker/Dockerfile.native-micro | 32 +++++ .../src/main/java/org}/example/App.java | 2 +- .../src/main/java/org}/example/Resources.java | 2 +- .../src/main/resources/application.properties | 0 .../main/resources/org}/example/config.json | 12 -- .../kuadrant-example}/src/main/wasm/README.md | 0 .../src/main/wasm/wasm_shim.wasm | Bin .../org}/example/LimitadorTestContainer.java | 2 +- .../test/java/org}/example/ResourcesTest.java | 17 +-- .../test/resources/org}/example/limits.yaml | 0 quarkus-x-corazawaf-example/.gitignore | 45 ------- .../src/main/resources/application.properties | 2 - quarkus-x-kuadrant-example/.gitignore | 45 ------- 41 files changed, 705 insertions(+), 434 deletions(-) delete mode 100644 quarkus-proxy-wasm-example/.gitignore delete mode 100644 quarkus-proxy-wasm-example/pom.xml delete mode 100644 quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/App.java delete mode 100644 quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java delete mode 100644 quarkus-proxy-wasm-example/src/test/java/io/roastedroot/proxywasm/jaxrs/example/ResourcesTest.java create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/.dockerignore create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/README.md rename {quarkus-x-corazawaf-example => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example}/pom.xml (76%) create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.jvm create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.legacy-jar create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native-micro rename {quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org}/example/Admin.java (72%) rename {quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org}/example/Anything.java (98%) rename {quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org}/example/App.java (97%) rename {quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org}/example/Status.java (98%) rename {quarkus-proxy-wasm-example => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example}/src/main/resources/application.properties (100%) rename {quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org}/example/README.md (100%) rename {quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org}/example/coraza-proxy-wasm.wasm (100%) rename {quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org}/example/waf-config.json (100%) rename {quarkus-x-corazawaf-example/src/test/java/io/roastedroot/proxywasm/corazawaf => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/test/java/org}/example/ResourcesTest.java (99%) create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/.dockerignore create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/README.md rename {quarkus-x-kuadrant-example => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example}/pom.xml (78%) create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.jvm create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.legacy-jar create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native create mode 100644 quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native-micro rename {quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org}/example/App.java (97%) rename {quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org}/example/Resources.java (92%) rename {quarkus-x-kuadrant-example => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example}/src/main/resources/application.properties (100%) rename {quarkus-x-kuadrant-example/src/main/resources/io/roastedroot/proxywasm/kuadrant => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/resources/org}/example/config.json (73%) rename {quarkus-x-kuadrant-example => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example}/src/main/wasm/README.md (100%) rename {quarkus-x-kuadrant-example => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example}/src/main/wasm/wasm_shim.wasm (100%) rename {quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org}/example/LimitadorTestContainer.java (97%) rename {quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org}/example/ResourcesTest.java (72%) rename {quarkus-x-kuadrant-example/src/test/resources/io/roastedroot/proxywasm/kuadrant => quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/resources/org}/example/limits.yaml (100%) delete mode 100644 quarkus-x-corazawaf-example/.gitignore delete mode 100644 quarkus-x-corazawaf-example/src/main/resources/application.properties delete mode 100644 quarkus-x-kuadrant-example/.gitignore diff --git a/pom.xml b/pom.xml index c2e27da..674f4af 100644 --- a/pom.xml +++ b/pom.xml @@ -248,9 +248,6 @@ quarkus-proxy-wasm - quarkus-proxy-wasm-example - quarkus-x-corazawaf-example - quarkus-x-kuadrant-example diff --git a/quarkus-proxy-wasm-example/.gitignore b/quarkus-proxy-wasm-example/.gitignore deleted file mode 100644 index 91a800a..0000000 --- a/quarkus-proxy-wasm-example/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -#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 - -# Plugin directory -/.quarkus/cli/plugins/ -# TLS Certificates -.certs/ diff --git a/quarkus-proxy-wasm-example/pom.xml b/quarkus-proxy-wasm-example/pom.xml deleted file mode 100644 index d6eef1e..0000000 --- a/quarkus-proxy-wasm-example/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - 4.0.0 - - - io.roastedroot - proxy-wasm-java-host-parent - 1.0-SNAPSHOT - ../pom.xml - - - quarkus-proxy-wasm-example - jar - quarkus-proxy-wasm-example - - - - - ${quarkus.platform.group-id} - ${quarkus.platform.artifact-id} - ${quarkus.platform.version} - pom - import - - - - - - - com.google.code.gson - gson - 2.12.1 - - - io.quarkiverse.proxy-wasm - quarkus-proxy-wasm - ${project.version} - - - io.quarkus - quarkus-arc - true - - - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - - - - - ${quarkus.platform.group-id} - quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - native-image-agent - - - - - - maven-failsafe-plugin - ${surefire-plugin.version} - - - ${project.build.directory}/${project.build.finalName}-runner - org.jboss.logmanager.LogManager - ${maven.home} - - - - - - integration-test - verify - - - - - - maven-surefire-plugin - ${surefire-plugin.version} - - - org.jboss.logmanager.LogManager - ${maven.home} - - - - - - - - - native - - - native - - - - false - true - - - - - diff --git a/quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/App.java b/quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/App.java deleted file mode 100644 index 391a7ca..0000000 --- a/quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/App.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.roastedroot.proxywasm.jaxrs.example; - -import com.dylibso.chicory.experimental.aot.AotMachine; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import io.roastedroot.proxywasm.Plugin; -import io.roastedroot.proxywasm.PluginFactory; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.inject.Produces; -import java.nio.file.Path; - -/** - * Application configuration class for the proxy-wasm JAX-RS example. - * Sets up the Wasm PluginFactory for the example plugin. - */ -@ApplicationScoped -public class App { - - /** - * Default constructor. - */ - public App() { - // Default constructor - } - - private static WasmModule module = - Parser.parse( - Path.of("../proxy-wasm-java-host/src/test/go-examples/unit_tester/main.wasm")); - - /** - * Produces the PluginFactory for the example Wasm plugin. - * Configures the plugin with necessary settings like name, shared status, - * plugin configuration, and machine factory. - * - * @return A configured PluginFactory for the example plugin. - */ - @Produces - public PluginFactory example() { - return () -> - Plugin.builder(module) - .withName("example") - .withShared(true) - .withPluginConfig("{ \"type\": \"headerTests\" }") - .withMachineFactory(AotMachine::new) - .build(); - } -} diff --git a/quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java b/quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java deleted file mode 100644 index e1552ae..0000000 --- a/quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.roastedroot.proxywasm.jaxrs.example; - -import io.roastedroot.proxywasm.jaxrs.WasmPlugin; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; - -/** - * JAX-RS resource class for the proxy-wasm example. - * Defines endpoints for testing the Wasm plugin. - */ -@Path("/") -public class Resources { - - /** - * Default constructor. - */ - public Resources() { - // Default constructor - } - - /** - * Handles GET requests to the /test path. - * Applies the "example" Wasm plugin. - * - * @return A simple "Hello World" string. - */ - @Path("/test") - @GET - @WasmPlugin("example") // filter with example wasm plugin - public String example() { - return "Hello World"; - } -} diff --git a/quarkus-proxy-wasm-example/src/test/java/io/roastedroot/proxywasm/jaxrs/example/ResourcesTest.java b/quarkus-proxy-wasm-example/src/test/java/io/roastedroot/proxywasm/jaxrs/example/ResourcesTest.java deleted file mode 100644 index 98bd1a1..0000000 --- a/quarkus-proxy-wasm-example/src/test/java/io/roastedroot/proxywasm/jaxrs/example/ResourcesTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.roastedroot.proxywasm.jaxrs.example; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.equalTo; - -import io.quarkus.test.junit.QuarkusTest; -import org.junit.jupiter.api.Test; - -@QuarkusTest -public class ResourcesTest { - - @Test - public void reverse() throws InterruptedException { - - given().when() - .get("/test") - .then() - .statusCode(200) - .header("x-response-counter", "1") - .body(equalTo("Hello World")); - - given().when() - .get("/test") - .then() - .statusCode(200) - .header("x-response-counter", "2") - .body(equalTo("Hello World")); - } -} diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/.dockerignore b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/.dockerignore new file mode 100644 index 0000000..94810d0 --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/.dockerignore @@ -0,0 +1,5 @@ +* +!target/*-runner +!target/*-runner.jar +!target/lib/* +!target/quarkus-app/* \ No newline at end of file diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/README.md b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/README.md new file mode 100644 index 0000000..aa972d3 --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/README.md @@ -0,0 +1,62 @@ +# corazawaf-example + +This project uses Quarkus, the Supersonic Subatomic Java Framework. + +If you want to learn more about Quarkus, please visit its website: . + +## Running the application in dev mode + +You can run your application in dev mode that enables live coding using: + +```shell script +./mvnw quarkus:dev +``` + +> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at . + +## Packaging and running the application + +The application can be packaged using: + +```shell script +./mvnw package +``` + +It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. +Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. + +The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. + +If you want to build an _über-jar_, execute the following command: + +```shell script +./mvnw package -Dquarkus.package.jar.type=uber-jar +``` + +The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. + +## Creating a native executable + +You can create a native executable using: + +```shell script +./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 -Dnative -Dquarkus.native.container-build=true +``` + +You can then execute your native executable with: `./target/corazawaf-example-1.0.0-SNAPSHOT-runner` + +If you want to learn more about building native executables, please consult . + +## Provided Code + +### REST + +Easily start your REST Web Services + +[Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources) diff --git a/quarkus-x-corazawaf-example/pom.xml b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/pom.xml similarity index 76% rename from quarkus-x-corazawaf-example/pom.xml rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/pom.xml index 1fca7fe..0b83283 100644 --- a/quarkus-x-corazawaf-example/pom.xml +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/pom.xml @@ -2,16 +2,24 @@ 4.0.0 - - io.roastedroot - proxy-wasm-java-host-parent - 1.0-SNAPSHOT - ../pom.xml - - - quarkus-corazawaf-example + org.example + corazawaf-example + 1.0.0-SNAPSHOT jar - quarkus-corsa-waf-example + corsawaf-example + + + 3.14.0 + 17 + UTF-8 + UTF-8 + quarkus-bom + io.quarkus.platform + 3.21.3 + true + 3.5.2 + 1.0-SNAPSHOT + @@ -34,7 +42,7 @@ io.quarkiverse.proxy-wasm quarkus-proxy-wasm - ${project.version} + ${proxy-wasm.version} io.quarkus @@ -73,6 +81,13 @@ + + maven-compiler-plugin + ${compiler-plugin.version} + + true + + maven-failsafe-plugin ${surefire-plugin.version} @@ -119,5 +134,4 @@ - diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.jvm b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..0c541cc --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.jvm @@ -0,0 +1,98 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/corazawaf-example-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-jvm +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override +# the default JVM options, use `JAVA_OPTS_APPEND` to append options +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi9/openjdk-17:1.21 + +ENV LANGUAGE='en_US:en' + + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +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" ] + diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.legacy-jar b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.legacy-jar new file mode 100644 index 0000000..b629b15 --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.legacy-jar @@ -0,0 +1,94 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package -Dquarkus.package.jar.type=legacy-jar +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/corazawaf-example-legacy-jar . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-legacy-jar +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-legacy-jar +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override +# the default JVM options, use `JAVA_OPTS_APPEND` to append options +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi9/openjdk-17:1.21 + +ENV LANGUAGE='en_US:en' + + +COPY target/lib/* /deployments/lib/ +COPY target/*-runner.jar /deployments/quarkus-run.jar + +EXPOSE 8080 +USER 185 +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" ] diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..08b83b2 --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native @@ -0,0 +1,29 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/corazawaf-example . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example +# +# The ` registry.access.redhat.com/ubi8/ubi-minimal:8.10` base image is based on UBI 9. +# To use UBI 8, switch to `quay.io/ubi8/ubi-minimal:8.10`. +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root --chmod=0755 target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native-micro b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native-micro new file mode 100644 index 0000000..492da8b --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/docker/Dockerfile.native-micro @@ -0,0 +1,32 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# It uses a micro base image, tuned for Quarkus native executables. +# It reduces the size of the resulting container image. +# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/corazawaf-example . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example +# +# The `quay.io/quarkus/quarkus-micro-image:2.0` base image is based on UBI 9. +# To use UBI 8, switch to `quay.io/quarkus/quarkus-micro-image:2.0`. +### +FROM quay.io/quarkus/quarkus-micro-image:2.0 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root --chmod=0755 target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Admin.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Admin.java similarity index 72% rename from quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Admin.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Admin.java index a72d525..fe53f98 100644 --- a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Admin.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Admin.java @@ -1,11 +1,11 @@ -package io.roastedroot.proxywasm.corazawaf.example; +package org.example; import io.roastedroot.proxywasm.jaxrs.WasmPlugin; import jakarta.ws.rs.Path; /** * JAX-RS resource class for handling requests to the /admin path. - * Inherits functionality from the Anything class and applies the "waf" Wasm plugin. + * Inherits functionality from the org.example.Anything class and applies the "waf" Wasm plugin. */ @Path("/admin") @WasmPlugin("waf") // use the corsaWAF filter diff --git a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Anything.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Anything.java similarity index 98% rename from quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Anything.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Anything.java index 3902eb4..a2c51b2 100644 --- a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Anything.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Anything.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.corazawaf.example; +package org.example; import io.roastedroot.proxywasm.jaxrs.WasmPlugin; import jakarta.ws.rs.DELETE; diff --git a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/App.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/App.java similarity index 97% rename from quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/App.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/App.java index bb9ae77..76e1a5d 100644 --- a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/App.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/App.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.corazawaf.example; +package org.example; import com.dylibso.chicory.wasm.Parser; import com.dylibso.chicory.wasm.WasmModule; diff --git a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Status.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Status.java similarity index 98% rename from quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Status.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Status.java index fcd9f97..dd98b2e 100644 --- a/quarkus-x-corazawaf-example/src/main/java/io/roastedroot/proxywasm/corazawaf/example/Status.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/java/org/example/Status.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.corazawaf.example; +package org.example; import io.roastedroot.proxywasm.jaxrs.WasmPlugin; import jakarta.ws.rs.DELETE; diff --git a/quarkus-proxy-wasm-example/src/main/resources/application.properties b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/application.properties similarity index 100% rename from quarkus-proxy-wasm-example/src/main/resources/application.properties rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/application.properties diff --git a/quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf/example/README.md b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org/example/README.md similarity index 100% rename from quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf/example/README.md rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org/example/README.md diff --git a/quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf/example/coraza-proxy-wasm.wasm b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org/example/coraza-proxy-wasm.wasm similarity index 100% rename from quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf/example/coraza-proxy-wasm.wasm rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org/example/coraza-proxy-wasm.wasm diff --git a/quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf/example/waf-config.json b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org/example/waf-config.json similarity index 100% rename from quarkus-x-corazawaf-example/src/main/resources/io/roastedroot/proxywasm/corazawaf/example/waf-config.json rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/main/resources/org/example/waf-config.json diff --git a/quarkus-x-corazawaf-example/src/test/java/io/roastedroot/proxywasm/corazawaf/example/ResourcesTest.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/test/java/org/example/ResourcesTest.java similarity index 99% rename from quarkus-x-corazawaf-example/src/test/java/io/roastedroot/proxywasm/corazawaf/example/ResourcesTest.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/test/java/org/example/ResourcesTest.java index ca1c138..cbbd8af 100644 --- a/quarkus-x-corazawaf-example/src/test/java/io/roastedroot/proxywasm/corazawaf/example/ResourcesTest.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/corazawaf-example/src/test/java/org/example/ResourcesTest.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.corazawaf.example; +package org.example; import static io.restassured.RestAssured.given; diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/.dockerignore b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/.dockerignore new file mode 100644 index 0000000..94810d0 --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/.dockerignore @@ -0,0 +1,5 @@ +* +!target/*-runner +!target/*-runner.jar +!target/lib/* +!target/quarkus-app/* \ No newline at end of file diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/README.md b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/README.md new file mode 100644 index 0000000..0e058ac --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/README.md @@ -0,0 +1,62 @@ +# kuadrant-example + +This project uses Quarkus, the Supersonic Subatomic Java Framework. + +If you want to learn more about Quarkus, please visit its website: . + +## Running the application in dev mode + +You can run your application in dev mode that enables live coding using: + +```shell script +./mvnw quarkus:dev +``` + +> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at . + +## Packaging and running the application + +The application can be packaged using: + +```shell script +./mvnw package +``` + +It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. +Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. + +The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. + +If you want to build an _über-jar_, execute the following command: + +```shell script +./mvnw package -Dquarkus.package.jar.type=uber-jar +``` + +The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. + +## Creating a native executable + +You can create a native executable using: + +```shell script +./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 -Dnative -Dquarkus.native.container-build=true +``` + +You can then execute your native executable with: `./target/kuadrant-example-1.0.0-SNAPSHOT-runner` + +If you want to learn more about building native executables, please consult . + +## Provided Code + +### REST + +Easily start your REST Web Services + +[Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources) diff --git a/quarkus-x-kuadrant-example/pom.xml b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/pom.xml similarity index 78% rename from quarkus-x-kuadrant-example/pom.xml rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/pom.xml index 0e11511..297230a 100644 --- a/quarkus-x-kuadrant-example/pom.xml +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/pom.xml @@ -2,16 +2,26 @@ 4.0.0 - - io.roastedroot - proxy-wasm-java-host-parent - 1.0-SNAPSHOT - ../pom.xml - + org.example + kuadrant-example + 1.0.0-SNAPSHOT - quarkus-kuadrant-example jar - quarkus-kuadrant-example + kuadrant-example + + + 3.14.0 + 17 + UTF-8 + UTF-8 + quarkus-bom + io.quarkus.platform + 3.21.3 + true + 3.5.2 + 1.1.0 + 1.0-SNAPSHOT + @@ -26,15 +36,10 @@ - - com.google.code.gson - gson - 2.12.1 - io.quarkiverse.proxy-wasm quarkus-proxy-wasm - ${project.version} + ${proxy-wasm.version} io.quarkus @@ -86,7 +91,6 @@ - com.dylibso.chicory aot-maven-plugin-experimental @@ -98,12 +102,19 @@ wasm-aot-gen - io.roastedroot.proxywasm.kuadrant.example.internal.WasmShim + org.example.internal.WasmShim src/main/wasm/wasm_shim.wasm + + maven-compiler-plugin + ${compiler-plugin.version} + + true + + maven-failsafe-plugin ${surefire-plugin.version} @@ -150,5 +161,4 @@ - diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.jvm b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..0c541cc --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.jvm @@ -0,0 +1,98 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/corazawaf-example-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-jvm +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override +# the default JVM options, use `JAVA_OPTS_APPEND` to append options +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi9/openjdk-17:1.21 + +ENV LANGUAGE='en_US:en' + + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +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" ] + diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.legacy-jar b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.legacy-jar new file mode 100644 index 0000000..b629b15 --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.legacy-jar @@ -0,0 +1,94 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package -Dquarkus.package.jar.type=legacy-jar +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/corazawaf-example-legacy-jar . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-legacy-jar +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example-legacy-jar +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override +# the default JVM options, use `JAVA_OPTS_APPEND` to append options +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi9/openjdk-17:1.21 + +ENV LANGUAGE='en_US:en' + + +COPY target/lib/* /deployments/lib/ +COPY target/*-runner.jar /deployments/quarkus-run.jar + +EXPOSE 8080 +USER 185 +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" ] diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..08b83b2 --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native @@ -0,0 +1,29 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/corazawaf-example . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example +# +# The ` registry.access.redhat.com/ubi8/ubi-minimal:8.10` base image is based on UBI 9. +# To use UBI 8, switch to `quay.io/ubi8/ubi-minimal:8.10`. +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root --chmod=0755 target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native-micro b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native-micro new file mode 100644 index 0000000..492da8b --- /dev/null +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/docker/Dockerfile.native-micro @@ -0,0 +1,32 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# It uses a micro base image, tuned for Quarkus native executables. +# It reduces the size of the resulting container image. +# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/corazawaf-example . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/corazawaf-example +# +# The `quay.io/quarkus/quarkus-micro-image:2.0` base image is based on UBI 9. +# To use UBI 8, switch to `quay.io/quarkus/quarkus-micro-image:2.0`. +### +FROM quay.io/quarkus/quarkus-micro-image:2.0 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root --chmod=0755 target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant/example/App.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org/example/App.java similarity index 97% rename from quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant/example/App.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org/example/App.java index 3bd3737..7fe3a42 100644 --- a/quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant/example/App.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org/example/App.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.kuadrant.example; +package org.example; import io.roastedroot.proxywasm.LogHandler; import io.roastedroot.proxywasm.Plugin; diff --git a/quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant/example/Resources.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org/example/Resources.java similarity index 92% rename from quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant/example/Resources.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org/example/Resources.java index 714a6e9..53421b4 100644 --- a/quarkus-x-kuadrant-example/src/main/java/io/roastedroot/proxywasm/kuadrant/example/Resources.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/java/org/example/Resources.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.kuadrant.example; +package org.example; import io.roastedroot.proxywasm.jaxrs.WasmPlugin; import jakarta.ws.rs.GET; diff --git a/quarkus-x-kuadrant-example/src/main/resources/application.properties b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/resources/application.properties similarity index 100% rename from quarkus-x-kuadrant-example/src/main/resources/application.properties rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/resources/application.properties diff --git a/quarkus-x-kuadrant-example/src/main/resources/io/roastedroot/proxywasm/kuadrant/example/config.json b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/resources/org/example/config.json similarity index 73% rename from quarkus-x-kuadrant-example/src/main/resources/io/roastedroot/proxywasm/kuadrant/example/config.json rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/resources/org/example/config.json index ff024b9..edb5675 100644 --- a/quarkus-x-kuadrant-example/src/main/resources/io/roastedroot/proxywasm/kuadrant/example/config.json +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/resources/org/example/config.json @@ -31,18 +31,6 @@ } } ] - }, - { - "service": "limitadorB", - "scope": "basic", - "data": [ - { - "expression": { - "key": "a", - "value": "1" - } - } - ] } ] } diff --git a/quarkus-x-kuadrant-example/src/main/wasm/README.md b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/wasm/README.md similarity index 100% rename from quarkus-x-kuadrant-example/src/main/wasm/README.md rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/wasm/README.md diff --git a/quarkus-x-kuadrant-example/src/main/wasm/wasm_shim.wasm b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/wasm/wasm_shim.wasm similarity index 100% rename from quarkus-x-kuadrant-example/src/main/wasm/wasm_shim.wasm rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/main/wasm/wasm_shim.wasm diff --git a/quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant/example/LimitadorTestContainer.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org/example/LimitadorTestContainer.java similarity index 97% rename from quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant/example/LimitadorTestContainer.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org/example/LimitadorTestContainer.java index 1d72645..efe8d0b 100644 --- a/quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant/example/LimitadorTestContainer.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org/example/LimitadorTestContainer.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.kuadrant.example; +package org.example; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; import java.io.IOException; diff --git a/quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant/example/ResourcesTest.java b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org/example/ResourcesTest.java similarity index 72% rename from quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant/example/ResourcesTest.java rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org/example/ResourcesTest.java index f395c6b..4d0eafb 100644 --- a/quarkus-x-kuadrant-example/src/test/java/io/roastedroot/proxywasm/kuadrant/example/ResourcesTest.java +++ b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/java/org/example/ResourcesTest.java @@ -1,4 +1,4 @@ -package io.roastedroot.proxywasm.kuadrant.example; +package org.example; import static io.restassured.RestAssured.given; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; @@ -18,9 +18,10 @@ public class ResourcesTest { @Test public void testCountersRemaining() throws InterruptedException { - var remaining = 28; + var remaining = 30; while (remaining > 0) { given().header("Host", "test.example.com").when().get("/").then().statusCode(200); + remaining -= 1; given().when() .get(limitadorUrl + "/counters/basic") .then() @@ -28,25 +29,15 @@ public void testCountersRemaining() throws InterruptedException { .body( sameJSONAs(String.format("[{\"remaining\":%s}]", remaining)) .allowingExtraUnexpectedFields()); - remaining -= 2; } - given().header("Host", "test.example.com").when().get("/").then().statusCode(200); - given().when() - .get(limitadorUrl + "/counters/basic") - .then() - .statusCode(200) - .body( - sameJSONAs(String.format("[{\"remaining\":%s}]", remaining)) - .allowingExtraUnexpectedFields()); - given().header("Host", "test.example.com").when().get("/").then().statusCode(429); given().when() .get(limitadorUrl + "/counters/basic") .then() .statusCode(200) .body( - sameJSONAs(String.format("[{\"remaining\":%s}]", remaining)) + sameJSONAs(String.format("[{\"remaining\":%s}]", 0)) .allowingExtraUnexpectedFields()); } } diff --git a/quarkus-x-kuadrant-example/src/test/resources/io/roastedroot/proxywasm/kuadrant/example/limits.yaml b/quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/resources/org/example/limits.yaml similarity index 100% rename from quarkus-x-kuadrant-example/src/test/resources/io/roastedroot/proxywasm/kuadrant/example/limits.yaml rename to quarkus-proxy-wasm/docs/modules/ROOT/example-projects/kuadrant-example/src/test/resources/org/example/limits.yaml diff --git a/quarkus-x-corazawaf-example/.gitignore b/quarkus-x-corazawaf-example/.gitignore deleted file mode 100644 index 91a800a..0000000 --- a/quarkus-x-corazawaf-example/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -#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 - -# Plugin directory -/.quarkus/cli/plugins/ -# TLS Certificates -.certs/ diff --git a/quarkus-x-corazawaf-example/src/main/resources/application.properties b/quarkus-x-corazawaf-example/src/main/resources/application.properties deleted file mode 100644 index 6e516f2..0000000 --- a/quarkus-x-corazawaf-example/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -quarkus.log.level=INFO -quarkus.log.category."org.hibernate".level=DEBUG diff --git a/quarkus-x-kuadrant-example/.gitignore b/quarkus-x-kuadrant-example/.gitignore deleted file mode 100644 index 91a800a..0000000 --- a/quarkus-x-kuadrant-example/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -#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 - -# Plugin directory -/.quarkus/cli/plugins/ -# TLS Certificates -.certs/